USE [KN_ONLINE]
GO
/****** Object: StoredProcedure [dbo].[ACCOUNT_LOGIN] Script Date: 06/16/2021 12:51:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ACCOUNT_LOGIN]
@AccountID varchar(21),
@Password varchar(32),
@nRet smallint OUTPUT
AS
----------------------------------Client Auto Account Registration---------------------------
--select @nRet = count(straccountid) from tb_user where straccountid = @AccountID
--if @nRet = 0
--begin
--insert into tb_user (straccountid, strpasswd, strSocNo, idays, strAuthority) values (@AccountID, @password, 1, '6', 1)
--end
-----------------------------------Process Login----------------------------------------
DECLARE @Nation tinyint, @CharNum smallint, @PremyName varchar(21), @Auth tinyint, @Charid char(21)
SET @Nation = 0
SET @CharNum = 0
DECLARE @pwd varchar(32)
SET @pwd = null
SELECT @pwd = strPasswd FROM TB_USER WHERE strAccountID = @AccountID and idays>0
IF @pwd IS null
BEGIN
--SET @nRet = 0
SET @nRet = 4
RETURN
END
ELSE IF @pwd <> @Password
BEGIN
--SET @nRet = 0
SET @nRet = 3
RETURN
END
------------------------------ Define Changes ------------------------------------------
---update userdata set zone = 21 where zone = 202
----Update userdata set level = 70, Exp = 500000000, strskill = 'z' , dex = 5, strong = 5, sta = 5, cha = 5, intel = 5 where level > 70
----exec RunDupeCheckInn @AccountID
----------------------------Premium Check-----------------------------------------------
--select @PremyName = strAccountID from PREMIUM_CHECK where strAccountID = @AccountID
---IF @PremyName = @AccountID -- Define Premium Account Name Block
--BEGIN
--SET @nRet = 12 -- Give notice "Your Premium days have expired, Please visit the Panel to select Normal Account mode"
---RETURN
--END
---------------------------------ban check----------------------------------------------
select @Auth = strAuthority from TB_USER where strAccountID = @AccountID
IF @Auth = 255 -- Define login Blocked (TB_USER 'strAuthority')
BEGIN
SET @nRet = 4 -- Give Notice "Your Account is currently Blocked. Please contact customer Support"
RETURN
END
else IF @Auth = 1 -- Define Allowed Login (TB_USER 'strAuthority')
BEGIN
SET @nRet = 1 -- Successfull Transaction
RETURN
END
------------------------------Successfull Transaction-----------------------------------
SELECT @Nation = bNation, @CharNum = bCharNum FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
IF @@ROWCOUNT = 0
BEGIN
SET @nRet = 1
RETURN
END
IF @CharNum = 0
BEGIN
SET @nRet = 1
RETURN
END
ELSE
BEGIN
SET @nRet = 1
RETURN
END