用户登录  | 
首 页技术文章软件发布广告价格
当前位置:传奇游戏服务端下载站传奇站长论坛资源网站程序技术文章文章资讯游戏架设教程奇迹技术

新建角色指定属性SQL语句

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2014-10-03 18:59:43

新建角色的等级指定代码(你可以指定各种属性值),必要的注释也有了,已编译通过:


use muonline
go

dedecms.com

CREATE Procedure  WZ_CreateCharacter
    @AccountID        varchar(10),
    @Name            varchar(10),
    @Class            tinyint
AS
Begin

    SET NOCOUNT ON
    SET    XACT_ABORT ON
    DECLARE        @Result        tinyint
    DECLARE    @FASHI        int            --变量声明
    DECLARE    @ZHANSHI    int
    DECLARE    @JINGLING    int
    DECLARE    @MOJIAN        int
    DECLARE    @SHENGDAO    int
    DECLARE    @BORNMONEY    int
    DECLARE    @BORNLEVEL    int   --添加对新建等级的变量的声明,类型为 int

    SET @Result = 0x00   
    SET @FASHI=    300            -- 法师出生点数
    SET @ZHANSHI=    300            -- 战士出生点数
    SET @JINGLING=    300            -- 精灵出生点数
    SET @MOJIAN=    400            -- 魔剑出生点数
    SET @SHENGDAO=    400            -- 圣导出生点数
    SET @BORNMONEY=    20000000            -- 出生送的钱
    SET @BORNLEVEL=    30            -- 新建立时的角色等级,你可以自己修改,我这里的例子是30级,但不要超出限度


    If EXISTS ( SELECT  Name  FROM  Character WHERE Name = @Name )
    begin
        SET @Result    = 0x01                       
        GOTO ProcEnd                       
    end

    BEGIN TRAN

    If NOT EXISTS ( SELECT  Id  FROM  AccountCharacter WHERE Id = @AccountID )
        begin
            INSERT INTO dbo.AccountCharacter(Id, GameID1, GameID2, GameID3, GameID4, GameID5, GameIDC)
            VALUES(@AccountID, @Name, NULL, NULL, NULL, NULL, NULL)

            SET @Result  = @@Error
        end
    else
        begin
            Declare @g1 varchar(10), @g2 varchar(10), @g3 varchar(10), @g4 varchar(10), @g5 varchar(10)                       
            SELECT @g1=GameID1, @g2=GameID2, @g3=GameID3, @g4=GameID4, @g5=GameID5 FROM dbo.AccountCharacter Where Id = @AccountID           
            if( ( @g1 Is NULL) OR (Len(@g1) = 0)) dedecms.com

                begin
                    UPDATE AccountCharacter SET  GameID1 = @Name
                    WHERE Id = @AccountID
                                       
                    SET @Result  = @@Error
                end
            else    if( @g2  Is NULL OR Len(@g2) = 0)
                begin
                    UPDATE AccountCharacter SET  GameID2 = @Name
                    WHERE Id = @AccountID

                    SET @Result  = @@Error
                end
            else    if( @g3  Is NULL OR Len(@g3) = 0)
                begin           
                    UPDATE AccountCharacter SET  GameID3 = @Name
                    WHERE Id = @AccountID

                    SET @Result  = @@Error
                end
            else    if( @g4 Is NULL OR Len(@g4) = 0)
                begin
                    UPDATE AccountCharacter SET  GameID4 = @Name
                    WHERE Id = @AccountID

                    SET @Result  = @@Error
                end
            else    if( @g5 Is NULL OR Len(@g5) = 0)
                begin
                    UPDATE AccountCharacter SET  GameID5 = @Name
                    WHERE Id = @AccountID

                    SET @Result  = @@Error
                end       
            else
                begin                   
                    SET @Result    = 0x03                           
                    GOTO TranProcEnd                               
                end             
        end dedecms.com

    if( @Result <> 0 )
        begin
            GOTO TranProcEnd       
        end
    else
        begin
        DECLARE    @UPPOINT int
        if(@Class=0)
            begin
            SET @UPPOINT  = @FASHI           
            --SET @BORNLEVEL = 10     --也可以在这里对各职业进行指定的等级,举例为10级
            end
        else if(@Class=16)


            begin
            SET @UPPOINT  = @ZHANSHI
            --SET @BORNLEVEL = 12     --也可以在这里对各职业进行指定的等级,举例为12级
            end
        else if(@Class=32)
            begin
            SET @UPPOINT  = @JINGLING
            --SET @BORNLEVEL = 13     --也可以在这里对各职业进行指定的等级,举例为13级
            end
        else if(@Class=48)
            begin
            SET @UPPOINT  = @MOJIAN
            --SET @BORNLEVEL = 14     --也可以在这里对各职业进行指定的等级,举例为14级
            end
        else
            begin
            SET @UPPOINT  = @SHENGDAO
            --SET @BORNLEVEL = 8     --也可以在这里对各职业进行指定的等级,举例为8级
            end

        INSERT INTO dbo.Character(AccountID, Name, cLevel, LevelUpPoint, Class, Strength, Dexterity, Vitality, Energy, Inventory,MagicList,
                Life, MaxLife, Mana, MaxMana, MapNumber, MapPosX, MapPosY,  MDate, LDate, Quest, DbVersion, Leadership,money )
        SELECT @AccountID As AccountID, @Name As Name, @BORNLEVEL AS Level,@UPPOINT AS LevelUpPoint,@Class As Class,
            Strength, Dexterity, Vitality, Energy, Inventory,MagicList,  Life, MaxLife, Mana, MaxMana, MapNumber, MapPosX, MapPosY,
            getdate() As MDate, getdate() As LDate, Quest, DbVersion, Leadership,@BORNMONEY As money
        FROM  DefaultClassType WHERE Class = @Class                    dedecms.com

        SET @Result  = @@Error
        end

TranProcEnd:
    IF ( @Result  <> 0 )
        ROLLBACK TRAN
    ELSE
        COMMIT    TRAN

ProcEnd:
    SET NOCOUNT OFF
    SET    XACT_ABORT OFF


    SELECT
      CASE @Result
          WHEN 0x00 THEN 0x01
          WHEN 0x01 THEN 0x00
          WHEN 0x03 THEN 0x03
          ELSE 0x02   
      END AS Result
End
GO

商业完整版游戏发布站程序免费下载:www.98youx.com

Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
传奇资源网提供最新传奇开区一条龙版本下载,本站声明:只更新最新最好的传奇服务端分享给大家。