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] Item Type ( PRIM | IDT_PRIM (79) )

Junior Spellweaver
Joined
Apr 2, 2023
Messages
195
Reaction score
84
The following will be absolutely useless for anyone who had enough curiosity to look through the database contents.
The only reason for me to post this is because I had multiple conversations with members of the cabal section having trouble to deal with this item type.
The item type called "PRIM" (or "- IDT_PRIM (79)" if going by the item template using Sweetscape) communicates with the database if right-clicking the item and confirming the use on the pop up after.

The item itself is simple enough, it can make use of level and honor rank restrictions just like any usable item.

Now a vague part that I'm not sure if it should even be in here:
The "attack_rate__opt_1" part of the item.dec (again, using Sweetscape + item template) might be responsible for it to show the premium service that belongs to the ID entered here, if it does - you can just give it some unused number and it won't. Shocking, I know.

Now lets turn the item that currently does as much as a magikarp into whatever evil creation it is that you're looking to build.

Allowing your database to make use of PRIM items
Account -> Programmability -> Stored Procedures -> [Right Click] "dbo.CABAL_SP_USE_PREMIUMITEM" -> Modify

Keep the following line of your procedure in mind, while editing it:
SQL:
ALTER procedure [dbo].[CABAL_SP_USE_PREMIUMITEM](@UserNum int, @GoodsNum int)

As obvious as it may be: UserNum represents the UserNum from the account that used the item, GoodsNum represents the OPTION ID from the PRIM item.
PRIM type items rely on their option id entirely, so you can have a single PRIM type of item and grant different option id's to it if you want.

Getting the character idx from the character that used the item
Replace the following:
SQL:
SET @ExpireDate = DATEDIFF(second, DATEADD(hour, DATEDIFF(hour, GETUTCDATE(), GETDATE()), '1970-01-01'), @OutputExpireDate)
With:
SQL:
SELECT @ExpireDate = (SELECT Top 1 CharacterIdx FROM Server01.dbo.cabal_character_table WHERE CharacterIdx/8 = @UserNum AND Login = '1' )

Giving each option id a use
It is as simple as
SQL:
    IF @GoodsNum = '61'    --USING THE OPTION ID 61 AS EXAMPLE
    BEGIN UPDATE MyFancy.dbo.Table SET CoolValue = CoolValue + 1 WHERE UserNum = @UserNum END;    --KEEP IN MIND THAT YOU DO NOT HAVE MY FANCY TABLE...

Examples
SQL:
IF @GoodsNum = 1    --Sends a specified item to the cash inventory, you can grab one from another table to randomize this.
BEGIN EXEC CabalCash.dbo.up_AddMyCashItemByItem @UserNum,'110010010','1','2366','500','0' END;

IF @GoodsNum = 2    --Adds 500 eCoins to the user
BEGIN UPDATE CabalCash.dbo.CashAccount SET Cash = Cash + 500 WHERE UserNum = @UserNum END;

IF @GoodsNum = 3    --Enables the Event using the EventID 5
BEGIN
    IF (SELECT EndDate FROM EventData.dbo.cabal_ems_event_table WHERE EventID = 5) < GETDATE()    --Confirming that it is not active anymore.
    BEGIN
        UPDATE EventData.dbo.cabal_ems_event_table SET EndDate = DATEADD(MINUTE,30,GETDATE()) WHERE EventID = 5    --The event end is set to 30 minutes from the moment of the item activation
        UPDATE EventData.dbo.cabal_ems_event_npcscript_table SET Script1 = 'The adventurer $4#' + @chaName + '$ has launched the fancy event! \\Event ends at: ' + CONVERT(VARCHAR,  DATEADD(MINUTE,30,GETDATE()), 108) WHERE EventID = 5    --The event script will display the character name as well as the event end time
        UPDATE EventData.dbo.cabal_ems_event_table SET UseFlag = '1' WHERE EventID = 5    --Finally enabling the event
    END
    ELSE
    BEGIN
        BEGIN EXEC CabalCash.dbo.up_AddMyCashItemByItem @UserNum,'100000000','1','3860','3','0' END    --My PRIM item for this example has the item id 3860 and option id 3, I am using this to send it back if the event was running already
    END
END

To use the EventData lines you will need this (at least the SET line has to be below the ExpireDate's line or it won't do a thing):
SQL:
DECLARE @chaName varchar(850)

SET @chaName = (SELECT [Name] FROM Server01.dbo.cabal_character_table WHERE CharacterIdx = @ExpireDate)


That's it.
I could have probably have shortened all this by excluding a bunch of additions or polishing the example lines, but I just had a coffee, so deal with it.

If I overlooked an already existing tut somewhere covering the same topic then just delete this one. 🤷‍♂️
 
Back
Top