Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Database] How to create Stat Token - Bugless

Joined
Jul 24, 2011
Messages
806
Reaction score
615
What is the Stat Tokens?
Stat Tokens are an ingame items which allow you to add custom amount of Stat Point to the characters using via Account database CABAL_SP_USE_PREMIUMITEM stored procedure.
These tokens was used on my last server concept, in case if you wanna reuse it.

How secure is it?
It's 100% bugless, many defensive interaction implemented to avoid bugs.
Method is simple, they using a coin which is stored in own SQL variable, once they relog, it will apply to PNT.

Functions:
- Handling the different coin types. (You can customize the values)
- Checking the maximum stat cap. (You can customize the cap)
- Returning the unused/bugged tokens/items.


Code:
Create an AddPNT field into the game database (Server01) dbo.cabal_character_table

Account Databse -> Stored Procedures -> CABAL_SP_USE_PREMIUMITEM

SQL:
USE [Account]
GO
/****** Object:  StoredProcedure [dbo].[CABAL_SP_USE_PREMIUMITEM]    Script Date: 2024. 02. 12. 7:17:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[CABAL_SP_USE_PREMIUMITEM](@UserNum int, @GoodsNum int)
AS
BEGIN
    DECLARE @PREMIUMITEM_APPLY_OK int
    DECLARE @PREMIUMITEM_STANDBY_OK int
    DECLARE @PREMIUMITEM_ERROR int
    
    SET @PREMIUMITEM_APPLY_OK = 0x11
    SET @PREMIUMITEM_STANDBY_OK = 0x12
    SET @PREMIUMITEM_ERROR = 0x13
    
    DECLARE @Result int
    DECLARE @ServiceType int
    SET @ServiceType=1
    DECLARE @OutputExpireDate [DateTime]
    DECLARE @ExpireDate INT    --UTC
    SET @ExpireDate = CAST(DATEADD(DAY, 1, GETDATE()) as int)

    -- VARS
    DECLARE @CurrentChar int
    DECLARE @CurrentStats int
    DECLARE @CurrentDays int
    SELECT @CurrentChar = (SELECT Top 1 CharacterIdx FROM Server01.dbo.cabal_character_table WHERE CharacterIdx/8 = @userNum AND Login = '1' )
    SELECT @CurrentStats=STR+DEX+INT+PNT+AddPNT FROM Server01.dbo.cabal_character_table WHERE CharacterIdx=@CurrentChar

     -- Days for auto increase of limit.
     SET @CurrentDays = DATEDIFF(day, '2024-01-01 07:09:04.797', GETDATE())
    
     -- Stat Token types
     IF @goodsNum IN ('10','30','50','100','250','500','1000')
     BEGIN
        IF @CurrentStats + @GoodsNum <= 200000 + @CurrentDays * 5000
        BEGIN
            UPDATE Server01.dbo.cabal_character_table SET AddPNT = AddPnt + @GoodsNum, AddPNTDate = GETDATE() WHERE CharacterIdx=@CurrentChar

            SET @Result = @PREMIUMITEM_STANDBY_OK
        END
        ELSE
        BEGIN
            DECLARE @ItemID INT
            IF @GoodsNum='10'
            BEGIN
                SET @ItemID = '881'
            END
            ELSE IF @GoodsNum='30'
            BEGIN
                SET @ItemID = '882'
            END
            ELSE IF @GoodsNum='50'
            BEGIN
                SET @ItemID = '883'
            END
            ELSE IF @GoodsNum='100'
            BEGIN
                SET @ItemID = '884'
            END
            ELSE IF @GoodsNum='250'
            BEGIN
                SET @ItemID = '885'
            END
            ELSE IF @GoodsNum='500'
            BEGIN
                SET @ItemID = '886'
            END
            ELSE IF @GoodsNum='1000'
            BEGIN
                SET @ItemID = '887'
            END
            ELSE
            BEGIN
                SET @ItemID = '0'
            END

            IF @ItemID>'0'
            BEGIN
                EXEC Server01.dbo.cabal_sp_mail_send_GM @CurrentChar,
                                'Stat Point Add Failed',
                                'You reached your current stat limit. Your Limit increases by 5.000 Stats every day at 12AM Server Time.
You got the failed Token back.', @ItemID, @GoodsNum, 0

            END
            ELSE
                    EXEC Server01.dbo.cabal_sp_mail_send_GM @CurrentChar,
                        'Error',
                        @GoodsNum, 0, 0, 0

            SET @Result = @PREMIUMITEM_STANDBY_OK
        END
    END
    ELSE
    BEGIN
        SET @Result = @PREMIUMITEM_STANDBY_OK
    END
    
    
    
    SELECT @Result, @ServiceType, @ExpireDate
END

Server01 (gamedb) -> Stored Procedures dbo.get_cabal_character

SQL:
    DECLARE @AddPNT INT
    DECLARE @Login INT
    SELECT @AddPNT=AddPnt, @Login=Login FROM Server01.dbo.cabal_character_table WHERE CharacterIdx=@CHARACTERIDX
    IF (@CH_LEV = 200 AND @AddPNT>0 AND @Login=0)
    BEGIN
        SET @CH_PNT = @CH_PNT + @AddPNT
        DECLARE @statmessage varchar(255)
        SET @statmessage = 'Notice: ' + CAST(@AddPNT as varchar) + ' unallocated Stat Points got added to your character!'

        UPDATE Server01.dbo.cabal_character_table SET PNT=@CH_PNT, AddPnt = 0 WHERE CharacterIdx=@CHARACTERIDX
        EXEC Server01.dbo.cabal_sp_mail_send_GM @CHARACTERIDX,
            'Stat Points added',
            @statmessage, 0, 0, 0
    END

For ingame item simply use PRIM (79) item type both in server and client side, and only the item option matter for this script.

Good luck and have fun!
 
Newbie Spellweaver
Joined
Nov 16, 2018
Messages
83
Reaction score
7
The "AddPNTDate" error is checked.

AddPNT field has been added to dbo.cabal_character_table.
 
Newbie Spellweaver
Joined
Nov 16, 2018
Messages
83
Reaction score
7
You have to add that AddPNTDate (DateTime) field or remove that part from the code. That was used for Ranking (who reached the current maximum stat point first.)
Where should I add it?

Deleting addpntdate is the same.

Nothing happens.
 
█║▌║▌║TheMerc iful║▌║▌║█
Loyal Member
Joined
Jan 29, 2005
Messages
1,367
Reaction score
80
What is the Stat Tokens?
Stat Tokens are an ingame items which allow you to add custom amount of Stat Point to the characters using via Account database CABAL_SP_USE_PREMIUMITEM stored procedure.
These tokens was used on my last server concept, in case if you wanna reuse it.

How secure is it?
It's 100% bugless, many defensive interaction implemented to avoid bugs.
Method is simple, they using a coin which is stored in own SQL variable, once they relog, it will apply to PNT.

Functions:
- Handling the different coin types. (You can customize the values)
- Checking the maximum stat cap. (You can customize the cap)
- Returning the unused/bugged tokens/items.


Code:
Create an AddPNT field into the game database (Server01) dbo.cabal_character_table

Account Databse -> Stored Procedures -> CABAL_SP_USE_PREMIUMITEM

SQL:
USE [Account]
GO
/****** Object:  StoredProcedure [dbo].[CABAL_SP_USE_PREMIUMITEM]    Script Date: 2024. 02. 12. 7:17:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[CABAL_SP_USE_PREMIUMITEM](@UserNum int, @GoodsNum int)
AS
BEGIN
    DECLARE @PREMIUMITEM_APPLY_OK int
    DECLARE @PREMIUMITEM_STANDBY_OK int
    DECLARE @PREMIUMITEM_ERROR int
 
    SET @PREMIUMITEM_APPLY_OK = 0x11
    SET @PREMIUMITEM_STANDBY_OK = 0x12
    SET @PREMIUMITEM_ERROR = 0x13
 
    DECLARE @Result int
    DECLARE @ServiceType int
    SET @ServiceType=1
    DECLARE @OutputExpireDate [DateTime]
    DECLARE @ExpireDate INT    --UTC
    SET @ExpireDate = CAST(DATEADD(DAY, 1, GETDATE()) as int)

    -- VARS
    DECLARE @CurrentChar int
    DECLARE @CurrentStats int
    DECLARE @CurrentDays int
    SELECT @CurrentChar = (SELECT Top 1 CharacterIdx FROM Server01.dbo.cabal_character_table WHERE CharacterIdx/8 = @userNum AND Login = '1' )
    SELECT @CurrentStats=STR+DEX+INT+PNT+AddPNT FROM Server01.dbo.cabal_character_table WHERE CharacterIdx=@CurrentChar

     -- Days for auto increase of limit.
     SET @CurrentDays = DATEDIFF(day, '2024-01-01 07:09:04.797', GETDATE())
 
     -- Stat Token types
     IF @goodsNum IN ('10','30','50','100','250','500','1000')
     BEGIN
        IF @CurrentStats + @GoodsNum <= 200000 + @CurrentDays * 5000
        BEGIN
            UPDATE Server01.dbo.cabal_character_table SET AddPNT = AddPnt + @GoodsNum, AddPNTDate = GETDATE() WHERE CharacterIdx=@CurrentChar

            SET @Result = @PREMIUMITEM_STANDBY_OK
        END
        ELSE
        BEGIN
            DECLARE @ItemID INT
            IF @GoodsNum='10'
            BEGIN
                SET @ItemID = '881'
            END
            ELSE IF @GoodsNum='30'
            BEGIN
                SET @ItemID = '882'
            END
            ELSE IF @GoodsNum='50'
            BEGIN
                SET @ItemID = '883'
            END
            ELSE IF @GoodsNum='100'
            BEGIN
                SET @ItemID = '884'
            END
            ELSE IF @GoodsNum='250'
            BEGIN
                SET @ItemID = '885'
            END
            ELSE IF @GoodsNum='500'
            BEGIN
                SET @ItemID = '886'
            END
            ELSE IF @GoodsNum='1000'
            BEGIN
                SET @ItemID = '887'
            END
            ELSE
            BEGIN
                SET @ItemID = '0'
            END

            IF @ItemID>'0'
            BEGIN
                EXEC Server01.dbo.cabal_sp_mail_send_GM @CurrentChar,
                                'Stat Point Add Failed',
                                'You reached your current stat limit. Your Limit increases by 5.000 Stats every day at 12AM Server Time.
You got the failed Token back.', @ItemID, @GoodsNum, 0

            END
            ELSE
                    EXEC Server01.dbo.cabal_sp_mail_send_GM @CurrentChar,
                        'Error',
                        @GoodsNum, 0, 0, 0

            SET @Result = @PREMIUMITEM_STANDBY_OK
        END
    END
    ELSE
    BEGIN
        SET @Result = @PREMIUMITEM_STANDBY_OK
    END
 
 
 
    SELECT @Result, @ServiceType, @ExpireDate
END

Server01 (gamedb) -> Stored Procedures dbo.get_cabal_character

SQL:
    DECLARE @AddPNT INT
    DECLARE @Login INT
    SELECT @AddPNT=AddPnt, @Login=Login FROM Server01.dbo.cabal_character_table WHERE CharacterIdx=@CHARACTERIDX
    IF (@CH_LEV = 200 AND @AddPNT>0 AND @Login=0)
    BEGIN
        SET @CH_PNT = @CH_PNT + @AddPNT
        DECLARE @statmessage varchar(255)
        SET @statmessage = 'Notice: ' + CAST(@AddPNT as varchar) + ' unallocated Stat Points got added to your character!'

        UPDATE Server01.dbo.cabal_character_table SET PNT=@CH_PNT, AddPnt = 0 WHERE CharacterIdx=@CHARACTERIDX
        EXEC Server01.dbo.cabal_sp_mail_send_GM @CHARACTERIDX,
            'Stat Points added',
            @statmessage, 0, 0, 0
    END

For ingame item simply use PRIM (79) item type both in server and client side, and only the item option matter for this script.

Good luck and have fun!

so sorry but how to use these queries?

have already tried the first one and yet there are no mail has come? or any points added to my existing character in game?

1712586660040 - [Database] How to create Stat Token - Bugless - RaGEZONE Forums

1712586712866 - [Database] How to create Stat Token - Bugless - RaGEZONE Forums

thanks!
 

Attachments

You must be registered for see attachments list
█║▌║▌║TheMerc iful║▌║▌║█
Loyal Member
Joined
Jan 29, 2005
Messages
1,367
Reaction score
80
2nd part goes to wrong procedure..
how will this query be triggered? up until now the character has not received any items for the said points? for the first query that has been executed correctly.

when and how will it take effect?

is it if the character has reached its maximum level?

thanks!
 
Back
Top