搜索
 找回密码
 加入

1311 人物删除存储

chencjh 2009-10-29 15:45:38 2020
USE [KN_online]
GO

/****** Object: StoredProcedure [dbo].[DELETE_CHAR] Script Date: 06/25/2009 14:33:20 ******/
SET ANSI_NULLS ON GO

SET QUOTED_IDENTIFIER ON GO

CREATE PROCEDURE [dbo].[DELETE_CHAR]
@AccountID char(21),
@index tinyint,
@CharID char(21),
@SocNo char(15),
@nRet smallint OUTPUT
AS DECLARE @bCharNum tinyint, @charid1 char(21), @charid2 char(21), @charid3 char(21), @charid4 char(21), @charid5 char(21), @strSocNo char(15)
DECLARE @knightsindex smallint
SET @bCharNum = 0
SET @knightsindex = 0

SELECT @strSocNo = strSocNo FROM TB_USER WHERE strAccountID = @AccountID
IF @SocNo <> @strSocNo
BEGIN SET @nRet = 0
RETURN
END

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 smallint, @Bind smallint, @PX int, @PZ int, @PY int, @strSkill varchar(20), @strItem varchar(400)
DECLARE @Members smallint

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 = 0
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 = 0
RETURN
END
END

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
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 )
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 )

DELETE FROM USERDATA WHERE strUserId = @CharID
IF @@ERROR <> 0
BEGIN ROLLBACK TRAN
SET @nRet = 0
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 @nRet = 1
GO

7 回复

feifeixia
2009-6-30 16:59:41
点击查看详情
干嘛的
dean98
2009-9-20 17:01:28
路过,支持了
leonjaykai
2009-10-25 23:07:41
路過的~~~推~ 日後學
ctgwglzc
2009-10-26 15:56:37
猪头的服都倒了
wery0712 发表于 2009-10-26 15:43

就你小子会钻空子,哈
ctgwglzc
2009-10-27 21:35:01

正版删除程式

  1. ****** ??: ?? ???? dbo.DELETE_CHAR    ???? ??: 2002-11-14 ?? 11:18:03 ******/
  2. -- Scripted by Samma
  3. -- 2002.01.18
  4. -- 2002.08.19 Modified by samma because check social number
  5. -- 2002.10.11 Modified by Sungyong  because knights, knights_user table modify
  6. -- 2002 11.21 samma
  7. -- 2002. 12.24 sungyong
  8. -- 2004-07-13 modified by ZhiChang Peng
  9. -- 2004-09-10 modified by ZhiChang Peng
  10. CREATE PROCEDURE [dbo].[DELETE_CHAR]
  11. @AccountID        char(21),
  12. @index                tinyint,
  13. @nation_id        tinyint,
  14. @CharID        char(21),
  15. @SocNo        char(17),
  16. @nKnightsIndex  smallint OUTPUT,
  17. @nRet                 smallint OUTPUT
  18. AS
  19. DECLARE @bCharNum        tinyint, @charid1 char(21), @charid2 char(21), @charid3 char(21), @charid4 char(21), @charid5 char(21), @strSocNo char(17)
  20. DECLARE @knightsindex smallint
  21. DECLARE @ForbidFreeTime smalldatetime  -- inserted by ZhiChang Peng 204-07-13
  22.         SET @bCharNum = 0
  23.         SET @knightsindex = 0
  24.         SET @nKnightsIndex = 0
  25.         SET @ForbidFreeTime = '2000-01-01 00:00:00'
  26. -- inserted by ZhiChang Peng 2004-07-13
  27. -- 禁止玩家删除被临时或者永久停权的帐号中的角色
  28. SELECT @ForbidFreeTime = ForbidFreeTime FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
  29. IF @ForbidFreeTime > GETDATE()
  30. BEGIN
  31.         SET @nRet = -1
  32.         RETURN
  33. END
  34. -- inserted by brad 2004.2.17
  35. SELECT @strSocNo = strWarehousePW FROM WAREHOUSE WHERE strAccountID = @AccountID
  36. IF @strSocNo <> @SocNo
  37. BEGIN
  38.         SET @nRet = -1
  39.         RETURN
  40. END
  41. IF @nation_id <> 3        -- china
  42. BEGIN
  43.         SELECT @strSocNo = strSocNo FROM [Knight_Account].[dbo].[TB_USER] WHERE strAccountID = @AccountID
  44.         IF @SocNo <> @strSocNo
  45.         BEGIN
  46.                 SET @nRet = -1
  47.                 RETURN
  48.         END
  49. END
  50. SELECT * FROM  [Knight_Account].[dbo].[CURRENTUSER] WHERE strAccountID = @AccountID
  51. IF @@ROWCOUNT <> 0
  52. BEGIN
  53.         SET @nRet = -2
  54.         RETURN
  55. END
  56. -- inserted by samma 2003.07.10
  57. DECLARE @True smallint
  58. SET @True = 0
  59.         SELECT @charid1 = strCharID1, @charid2 = strCharID2, @charid3 = strCharID3 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
  60.         IF @CharID = @charid1 or @CharID = @charid2 or @CharID = @charid3
  61.                 SET @True = 1
  62.         IF @True = 0
  63.         BEGIN
  64.                 SET @nRet = 1
  65.                 RETURN
  66.         END
  67. -- inserted by samma 2003.07.10
  68. DECLARE        @Nation tinyint, @Race        tinyint, @Class        smallint, @HairColor tinyint, @Rank tinyint, @Title        tinyint, @Level tinyint, @Exp int, @Loyalty int
  69. DECLARE        @Face        tinyint, @City tinyint, @Knights        smallint, @Fame tinyint,        @Hp smallint, @Mp smallint,  @Sp smallint, @Strong tinyint, @Sta tinyint, @Dex tinyint
  70. 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
  71. DECLARE          @Members smallint
  72. 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
  73. BEGIN TRAN
  74.         IF @index = 0
  75.                 UPDATE ACCOUNT_CHAR SET strCHARID1 = NULL, bCharNum = bCharNum - 1 WHERE strAccountID = @AccountID
  76.         IF @index = 1
  77.                 UPDATE ACCOUNT_CHAR SET strCHARID2 = NULL, bCharNum = bCharNum - 1 WHERE strAccountID = @AccountID
  78.         IF @index = 2
  79.                 UPDATE ACCOUNT_CHAR SET strCHARID3 = NULL, bCharNum = bCharNum - 1 WHERE strAccountID = @AccountID
  80.         IF @index = 3
  81.                 UPDATE ACCOUNT_CHAR SET strCHARID4 = NULL, bCharNum = bCharNum - 1 WHERE strAccountID = @AccountID
  82.         IF @index = 4
  83.                 UPDATE ACCOUNT_CHAR SET strCHARID5 = NULL, bCharNum = bCharNum - 1 WHERE strAccountID = @AccountID
  84.         IF @@ERROR <> 0
  85.         BEGIN
  86.                 ROLLBACK TRAN
  87.                 SET @nRet = -2
  88.                 RETURN
  89.         END
  90.         SELECT @charid1 = strCHARID1, @charid2 = strCHARID2, @charid3 = strCHARID3, @charid4 = strCHARID4, @charid5 = strCHARID5 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
  91.         IF @charid1 = NULL and @charid2 = NULL and @charid3 = NULL and @charid4 = NULL and @charid5 = NULL          -- ???? ??? ??? ?? ???? ???.. -> ???? ?? ?? ??
  92.         BEGIN
  93.                 DELETE FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
  94.                 IF @@ERROR <> 0
  95.                 BEGIN
  96.                         ROLLBACK TRAN
  97.                         SET @nRet = -2
  98.                         RETURN
  99.                 END
  100.         END
  101. -- modify by zxujie  03.09.17
  102.         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,
  103.                  @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
  104.         FROM        USERDATA WHERE strUserId = @CharID
  105.         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)
  106.         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 )
  107. -- modify by zxujie  03.09.17
  108.         DELETE FROM USERDATA WHERE strUserId = @CharID
  109.         IF @@ERROR <> 0
  110.         BEGIN
  111.                 ROLLBACK TRAN
  112.                 SET @nRet = -2
  113.                 RETURN
  114.         END
  115.         DELETE FROM KNIGHTS_USER WHERE strUserId = @CharID
  116.         SELECT @Members=Members FROM KNIGHTS WHERE IDNum = @Knights
  117.         IF @Members <= 1
  118.                 UPDATE KNIGHTS SET Members = 1 WHERE IDNum = @Knights
  119.         ELSE
  120.                 UPDATE KNIGHTS SET Members = Members - 1 WHERE IDNum = @Knights
  121. COMMIT TRAN
  122. SET @nKnightsIndex  = @Knights
  123. SET @nRet = 1

  124. GO
复制代码
laoyou456
2009-10-29 14:03:45
evaydd
2009-10-29 15:45:38
是真的吗????
高级模式
游客