Since i didn't find anything released about and many admins still are not so familiar with SQL, I decided to share this easy way for prevent people to dual-box, statpad etc. that i just made for my server.
First off, if you read official rules from Shaiya, multilogin is not allowed for ANY reason from the same IP, but I'm the first that want allow everyone to play, even from the same IP, so i added an exceptions column that you can manage manually.
I know some admins allow players use multiaccount, but i prefer to prevent it instead go in the logs and spy players for see if they are using the multilogin properly!
First we need to store the UserIP on login, so we need to edit PS_UserData.dbo.UserLoginStatus:
Now we can start with the procedure that manage the login.
Open PS_UserData/programmability/Stored Procedures/dbo.usp_Try_GameLogin_taiwan rightclick/Modify.
On the bottom of the procedure You'll read:
Also in the same directory from dbo.usp_Try_GameLogin_taiwan open usp_Try_GameLogout_R
and before the last row add:
Only self kill Padding prevent
If you think that is to much don't allow people to multi login because the help that this give top players, but you like a bit more security, we can quickly edit this script for don't allow players to log inside the opposite faction.
If we look into the check of multi login Account:
and if you get error processing the querys READ IT BEFORE POST THE LOGS.
First off, if you read official rules from Shaiya, multilogin is not allowed for ANY reason from the same IP, but I'm the first that want allow everyone to play, even from the same IP, so i added an exceptions column that you can manage manually.
I know some admins allow players use multiaccount, but i prefer to prevent it instead go in the logs and spy players for see if they are using the multilogin properly!
First we need to store the UserIP on login, so we need to edit PS_UserData.dbo.UserLoginStatus:
Not less important we need that some Players will have the opportunity to login always so we add a column into PS_UserData.dbo.Users_Master:Quote:
USE [PS_UserData]
GO
/****** Object: Table [dbo].[UserLoginStatus] Script Date: 10/9/2016 1:38:53 AM ******/
DROP TABLE [dbo].[UserLoginStatus]
GO
/****** Object: Table [dbo].[UserLoginStatus] Script Date: 10/9/2016 1:38:53 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[UserLoginStatus](
[UserUID] [int] NOT NULL,
[UserIP] [varchar](15) NOT NULL, --Here we add the new column for check the User IP
[LoginStatus] [tinyint] NOT NULL,
[LoginTime] [datetime] NULL,
[LogoutTime] [datetime] NULL,
[LoginSession] [bigint] NULL,
[LogoutSession] [bigint] NULL,
[LastPlayTime] [int] NULL,
CONSTRAINT [PK_UserLoginStatus] PRIMARY KEY CLUSTERED
(
[UserUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
The column Exeption will be 0 for all players; You can set it to 1 for bypass the procedure.Quote:
ALTER TABLE PS_UserData.dbo.Users_Master
ADD Exception INT
ALTER TABLE [PS_UserData].[dbo].[Users_Master] ADD CONSTRAINT [DF_Users_Master_Exception] DEFAULT ((0)) FOR [Exception]
UPDATE PS_UserData.dbo.Users_Master SET Exception = 0
Now we can start with the procedure that manage the login.
Open PS_UserData/programmability/Stored Procedures/dbo.usp_Try_GameLogin_taiwan rightclick/Modify.
On the bottom of the procedure You'll read:
Here is where it EXECute the login after all previous checks. Let's edit it for add the check about the UserIP:Quote:
-- Select
SELECT @Status AS Status, @UserUID AS UserUID
-- Log Insert
IF( @Status = 0 OR @Status = 16 OR @Status = 32 OR @Status = 48 OR @Status = 64 OR @Status = 80 )
BEGIN
EXEC usp_Insert_LoginLog_E @SessionID=@SessionID, @UserUID=@UserUID, @UserIP=@UserIP, @LogType=0, @LogTime=@LoginTime, @LoginType=@LoginType
..
END
And last but not less important, let's edit the logout procedure for remove the loginstatus = 1 from the PS_userdata.dbo.UserLoginStatus.Quote:
-- check Multi Login Account
DECLARE @exception INT -- REMEMBER ALWAYS TO DECLARE A VARIABLE
DECLARE @logStatus INT
SET @exception = (SELECT Exception FROM dbo.Users_Master WHERE UserUID = @UserUID)
if @exception = 0
begin
SET @logStatus = (select loginstatus from PS_userdata.dbo.UserLoginStatus where UserIP = @userip AND LoginStatus =1)
if @logStatus = 1
begin
SET @Status = -3 -- If multi login status = -3
end
end
-- Select
SELECT @Status AS Status, @UserUID AS UserUID
-- Log Insert
IF( @Status = 0 OR @Status = 16 OR @Status = 32 OR @Status = 48 OR @Status = 64 OR @Status = 80 )
BEGIN
EXEC usp_Insert_LoginLog_E @SessionID=@SessionID, @UserUID=@UserUID, @UserIP=@UserIP, @LogType=0, @LogTime=@LoginTime, @LoginType=@LoginType
if @useruid=(select useruid from PS_userdata.dbo.UserLoginStatus where UserUID = @useruid)
update PS_userdata.dbo.UserLoginStatus
set loginstatus=1,UserIP=@UserIP,LoginTime=@LoginTime, LogoutTime=@LoginTime,loginSession=@SessionID,last playtime=0
where useruid=@useruid
else
insert into PS_userdata.dbo.UserLoginStatus(UserUID,UserIP,log instatus,logintime,logouttime,loginsession,lastpla ytime) values(@useruid,@UserIP,1,@LoginTime,@LoginTime,@S essionID,0)
END
Also in the same directory from dbo.usp_Try_GameLogin_taiwan open usp_Try_GameLogout_R
and before the last row add:
(read first, if you already have something similar to this, replace it)Quote:
update PS_userdata.dbo.UserLoginStatus set loginstatus=0,LogoutTime=@LogTime,loginSession=@Se ssionID,lastplaytime=0 where useruid=@Useruid
Only self kill Padding prevent
If you think that is to much don't allow people to multi login because the help that this give top players, but you like a bit more security, we can quickly edit this script for don't allow players to log inside the opposite faction.
If we look into the check of multi login Account:
We can add another if for see what faction is logged and if is different, block him:Quote:
-- check Multi Login Account
DECLARE @exception INT -- REMEMBER ALWAYS TO DECLARE A VARIABLE
DECLARE @logStatus INT
SET @exception = (SELECT Exception FROM dbo.Users_Master WHERE UserUID = @UserUID)
if @exception = 0
begin
if @logStatus=(select loginstatusfrom PS_userdata.dbo.UserLoginStatus where UserIP = @userip and loginstatus=1)
begin
SET @Status = -3 -- If multi login status = -3
end
end
I didn't test it yet on a open server, so for any issue just let me know..Quote:
-- check Multi Login Account
DECLARE @exception INT -- REMEMBER ALWAYS TO DECLARE A VARIABLE
DECLARE @logStatus INT
SET @exception = (SELECT Exception FROM dbo.Users_Master WHERE UserUID = @UserUID)
if @exception = 0
begin
SET @logStatus = (select loginstatus from PS_userdata.dbo.UserLoginStatus where UserIP = @userip)
if @logStatus = 1
begin
DECLARE @logUID INT
DECLARE @faction1 INT
DECLARE @faction2 INT
SET @logUID = (select UserUID from PS_userdata.dbo.UserLoginStatus where UserIP = @userip AND LoginStatus = 1)
SET @faction1 = (SELECT Country FROM PS_GameData.dbo.UserMaxGrow WHERE UserUID = @logUID)
SET @faction2 = (SELECT Country FROM PS_GameData.dbo.UserMaxGrow WHERE UserUID = @UserUID)
if @faction1 != @faction2
begin
SET @Status = -3 -- If multi login status = -3
end
end
end
and if you get error processing the querys READ IT BEFORE POST THE LOGS.