- ****** ??: ?? ???? dbo.DELETE_CHAR ???? ??: 2002-11-14 ?? 11:18:03 ******/
- -- Scripted by Samma
- -- 2002.01.18
- -- 2002.08.19 Modified by samma because check social number
- -- 2002.10.11 Modified by Sungyong because knights, knights_user table modify
- -- 2002 11.21 samma
- -- 2002. 12.24 sungyong
- -- 2004-07-13 modified by ZhiChang Peng
- -- 2004-09-10 modified by ZhiChang Peng
- CREATE PROCEDURE [dbo].[DELETE_CHAR]
- @AccountID char(21),
- @index tinyint,
- @nation_id tinyint,
- @CharID char(21),
- @SocNo char(17),
- @nKnightsIndex smallint OUTPUT,
- @nRet smallint OUTPUT
- AS
- DECLARE @bCharNum tinyint, @charid1 char(21), @charid2 char(21), @charid3 char(21), @charid4 char(21), @charid5 char(21), @strSocNo char(17)
- DECLARE @knightsindex smallint
- DECLARE @ForbidFreeTime smalldatetime -- inserted by ZhiChang Peng 204-07-13
- SET @bCharNum = 0
- SET @knightsindex = 0
- SET @nKnightsIndex = 0
- SET @ForbidFreeTime = '2000-01-01 00:00:00'
- -- inserted by ZhiChang Peng 2004-07-13
- -- 禁止玩家删除被临时或者永久停权的帐号中的角色
- SELECT @ForbidFreeTime = ForbidFreeTime FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
- IF @ForbidFreeTime > GETDATE()
- BEGIN
- SET @nRet = -1
- RETURN
- END
- -- inserted by brad 2004.2.17
- SELECT @strSocNo = strWarehousePW FROM WAREHOUSE WHERE strAccountID = @AccountID
- IF @strSocNo <> @SocNo
- BEGIN
- SET @nRet = -1
- RETURN
- END
- IF @nation_id <> 3 -- china
- BEGIN
- SELECT @strSocNo = strSocNo FROM [Knight_Account].[dbo].[TB_USER] WHERE strAccountID = @AccountID
- IF @SocNo <> @strSocNo
- BEGIN
- SET @nRet = -1
- RETURN
- END
- END
- SELECT * FROM [Knight_Account].[dbo].[CURRENTUSER] WHERE strAccountID = @AccountID
- IF @@ROWCOUNT <> 0
- BEGIN
- SET @nRet = -2
- RETURN
- END
- -- inserted by samma 2003.07.10
- DECLARE @True smallint
- SET @True = 0
- SELECT @charid1 = strCharID1, @charid2 = strCharID2, @charid3 = strCharID3 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
- IF @CharID = @charid1 or @CharID = @charid2 or @CharID = @charid3
- SET @True = 1
- IF @True = 0
- BEGIN
- SET @nRet = 1
- RETURN
- END
- -- inserted by samma 2003.07.10
- DECLARE @Nation tinyint, @Race tinyint, @Class smallint, @HairColor tinyint, @Rank tinyint, @Title tinyint, @Level tinyint, @Exp int, @Loyalty int
- DECLARE @Face tinyint, @City tinyint, @Knights smallint, @Fame tinyint, @Hp smallint, @Mp smallint, @Sp smallint, @Strong tinyint, @Sta tinyint, @Dex tinyint
- DECLARE @Intel tinyint, @Cha tinyint, @Authority tinyint, @Points tinyint, @Gold int, @Zone tinyint, @Bind smallint, @PX int, @PZ int, @PY int, @strSkill varchar(20), @strItem varchar(400), @strSerial varchar(400) -- @strSerial added by ZhiChang Peng 2004-09-10
- DECLARE @Members smallint
- DECLARE @sQuestCount smallint, @strQuest varchar(400), @MannerPoint int, @LoyaltyMonthly int-- add by zxujie 03.09.17,MannerPoint added by pengzc 040323, LoyaltyMonthly added by pengzc 040529
- BEGIN TRAN
- IF @index = 0
- UPDATE ACCOUNT_CHAR SET strCHARID1 = NULL, bCharNum = bCharNum - 1 WHERE strAccountID = @AccountID
- IF @index = 1
- UPDATE ACCOUNT_CHAR SET strCHARID2 = NULL, bCharNum = bCharNum - 1 WHERE strAccountID = @AccountID
- IF @index = 2
- UPDATE ACCOUNT_CHAR SET strCHARID3 = NULL, bCharNum = bCharNum - 1 WHERE strAccountID = @AccountID
- IF @index = 3
- UPDATE ACCOUNT_CHAR SET strCHARID4 = NULL, bCharNum = bCharNum - 1 WHERE strAccountID = @AccountID
- IF @index = 4
- UPDATE ACCOUNT_CHAR SET strCHARID5 = NULL, bCharNum = bCharNum - 1 WHERE strAccountID = @AccountID
- IF @@ERROR <> 0
- BEGIN
- ROLLBACK TRAN
- SET @nRet = -2
- RETURN
- END
- SELECT @charid1 = strCHARID1, @charid2 = strCHARID2, @charid3 = strCHARID3, @charid4 = strCHARID4, @charid5 = strCHARID5 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
- IF @charid1 = NULL and @charid2 = NULL and @charid3 = NULL and @charid4 = NULL and @charid5 = NULL -- ???? ??? ??? ?? ???? ???.. -> ???? ?? ?? ??
- BEGIN
- DELETE FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
- IF @@ERROR <> 0
- BEGIN
- ROLLBACK TRAN
- SET @nRet = -2
- RETURN
- END
- END
- -- modify by zxujie 03.09.17
- SELECT @Nation = Nation, @Race = Race, @Class = Class, @HairColor = HairColor, @Rank = Rank, @Title = Title, @Level = [Level], @Exp = [Exp], @Loyalty = Loyalty, @Face = Face, @City = City, @Knights = Knights, @Fame = Fame,
- @Hp = Hp, @Mp = Mp, @Sp = Sp, @Strong = Strong, @Sta = Sta, @Dex = Dex, @Intel = Intel, @Cha = Cha, @Authority = Authority, @Points = Points, @Gold = Gold, @Zone = [Zone], @Bind = Bind, @PX = PX, @PZ = PZ, @PY = PY, @strSkill = strSkill, @strItem = strItem, @strSerial = strSerial, @sQuestCount = sQuestCount, @strQuest = strQuest, @MannerPoint = MannerPoint, @LoyaltyMonthly = LoyaltyMonthly
- FROM USERDATA WHERE strUserId = @CharID
- INSERT INTO DELETED_USERDATA (strAccountID, strUserID, Nation, Race, Class, HairColor, Rank, Title, [Level], [Exp], Loyalty, Face, City, Knights, Fame, Hp, Mp, Sp, Strong, Sta, Dex, Intel, Cha, Authority, Points, Gold, [Zone], Bind, PX, PZ, PY, strSkill, strItem, strSerial, sQuestCount, strQuest, MannerPoint, LoyaltyMonthly)
- VALUES ( @AccountID, @CharID, @Nation, @Race, @Class, @HairColor, @Rank, @Title, @Level, @Exp, @Loyalty, @Face, @City, @Knights, @Fame, @Hp, @Mp, @Sp, @Strong, @Sta, @Dex, @Intel, @Cha, @Authority, @Points, @Gold, @Zone, @Bind, @PX, @PZ, @PY, @strSkill, @strItem, @strSerial, @sQuestCount, @strQuest, @MannerPoint, @LoyaltyMonthly )
- -- modify by zxujie 03.09.17
- DELETE FROM USERDATA WHERE strUserId = @CharID
- IF @@ERROR <> 0
- BEGIN
- ROLLBACK TRAN
- SET @nRet = -2
- RETURN
- END
- DELETE FROM KNIGHTS_USER WHERE strUserId = @CharID
- SELECT @Members=Members FROM KNIGHTS WHERE IDNum = @Knights
- IF @Members <= 1
- UPDATE KNIGHTS SET Members = 1 WHERE IDNum = @Knights
- ELSE
- UPDATE KNIGHTS SET Members = Members - 1 WHERE IDNum = @Knights
- COMMIT TRAN
- SET @nKnightsIndex = @Knights
- SET @nRet = 1
- GO
复制代码 |