talkweb 发表于 2009-11-18 16:10:02

再要一个角色转换职业的存储,发下,发下.

再要一个角色转换职业的存储,发下,发下.
再要一个角色转换职业的存储,发下,发下.

最好还能来个删除角色的存储.哈哈...

感谢了..

ctgwglzc 发表于 2009-11-18 21:45:45

CREATE PROCEDURE .
@AccountID        char(21),
@index                tinyint,
@nation_id        tinyint,
@CharID        char(21),
@SocNo        char(17),
@nKnightsIndexsmallint 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'

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 .. WHERE strAccountID = @AccountID
        IF @SocNo <> @strSocNo
        BEGIN
                SET @nRet = -1
                RETURN
        END
END
SELECT * FROM.. 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 zxujie03.09.17
        SELECT @Nation = Nation, @Race = Race, @Class = Class, @HairColor = HairColor, @Rank = Rank, @Title = Title, @Level = , @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 = , @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, , , Loyalty, Face, City, Knights, Fame, Hp, Mp, Sp, Strong, Sta, Dex, Intel, Cha, Authority, Points, Gold, , 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 zxujie03.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

214550663 发表于 2009-11-24 19:10:14

CT,能否解释下呀?
页: [1]
查看完整版本: 再要一个角色转换职业的存储,发下,发下.