Firstly, I want you to make sure this thing: Silk only stores in Account
Secondly, if you want to add silk to new created Char... it means that your Silk can multiply five times (max number of Char in Account), because silk affects in Account, not Char!
Ex: You want to add 2 silk when they created new Char in xyz's account. If they created 5 characters, xyz's account would earn 10 silk => all of char in xyz's account could use that silk!
Finally, if you're sure what do you want... so let's begin!
*note: You should know a little bit MSSQL query and Trigger (for insert) => if you don't know it, go google!
Relational databases: SRO_VT_ACCOUNT and SRO_VT_SHARD
Relational tables: SK_SILK and _CHAR AND _USER
Description: When you created new char in game, _Char's table will be inserted new record to last row! (I guess client send request to server to let it know insert new record into _Char's table)
1> Create new Trigger for Insert and get last CharID's column record.
PHP Code:
CREATE TRIGGER trgAddSilk
ON SRO_VT_SHARD.._CHAR FOR INSERT
AS
DECLARE @CHARID int;
SET @CHARID = (SELECT TOP (1) CHARID FROM SRO_VT_SHARD.._CHAR ORDER BY CHARID DESC);
2> When you have Character's CharID, go to table _USER in SRO_VT_SHARD and find their UserJID.
PHP Code:
DECLARE @USERJID int;
SET @USERJID = (SELECT USERJID FROM SRO_VT_SHARD.._USER WHERE CHARID = @CHARID)
3> When you have Account's UserJID, go to table SK_SILK in SRO_VT_ACCOUNT and let's insert or update silk through their JID.
PHP Code:
INSERT INTO SRO_VT_ACCOUNT..SK_SILK VALUES (@USERJID, 0, 2, 0) //2 is amount of silk you want to add
or
PHP Code:
UPDATE SRO_VT_ACCOUNT..SK_SILK SET SILK_GIFT = SILK_GIFT + 2 WHERE JID = @USERJID //2 is amount of silk you want to add
***>>> Finish Trigger!
FULLY CODE
PHP Code:
CREATE TRIGGER trgAddSilk
ON SRO_VT_SHARD.._CHAR FOR INSERT
AS
DECLARE @CHARID int;
SET @CHARID = (SELECT TOP (1) CHARID FROM SRO_VT_SHARD.._CHAR ORDER BY CHARID DESC);
DECLARE @USERJID int;
SET @USERJID = (SELECT USERJID FROM SRO_VT_SHARD.._USER WHERE CHARID = @CHARID);
IF (SELECT COUNT(*) FROM SRO_VT_ACCOUNT..SK_SILK WHERE JID = @USERJID) > 0
UPDATE SRO_VT_ACCOUNT..SK_SILK SET SILK_GIFT = SILK_GIFT + 2 WHERE JID = @USERJID;
ELSE
INSERT INTO SRO_VT_ACCOUNT..SK_SILK VALUES (@USERJID, 0, 2, 0);
This is a basic code to let you add silk when you created new char in game!
Ofc you have to test it if you decide to use it!
Say Thanks if you see my post is usefull!