• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X Would be possible to add a storage and a addon to players offline?

sucibob

Member
Joined
Mar 28, 2017
Messages
128
Reaction score
13
Would be possible to add a storage and a addon to players offline?

I have this script base that adding donate points if player who was invited to play take lvl requiredLevel
Would be possible to add storages and addons?

Code:
function onAdvance(cid, skill, oldLevel, newLevel)


  local r = {
    [25] = {premmydays = 1, storage = 50010},
    [50] = {premmydays = 2, outfitid = 22, addon = 1},
    [100] = {premmydays = 4, outfitid = 22, addon = 2},
  }


   local requiredLevel = 15
   local bonusPoints = 5



   if skill == SKILL_LEVEL and newLevel >= requiredLevel then
     local accountId = getAccountId(cid)
     -- Fetch the ref_key where account_id = accountId and blocked = 0
     local resultId = db.storeQuery("SELECT `ref_key` FROM `__cornex_referral_actions` WHERE `registered_by` = " .. accountId .. " AND `blocked` = 0")
     -- If result is found
     if resultId ~= false then

       -- Fetch the referrer's account_id based on ref_key from previous query result
       local resultId2 = db.storeQuery("SELECT `belongs_to` FROM `__cornex_referral` WHERE `referral_key` = '" .. result.getDataString(resultId, "ref_key") .. "'")
         -- If result is found
       if resultId2 ~= false then
         -- Update accountId's row blocked value to 1
         db.executeQuery("UPDATE `__cornex_referral_actions` SET `blocked` = 1 WHERE `registered_by` = " .. accountId)
         -- Update points to referrer
         -- ADD ITEMS TO REFFERER
         db.executeQuery("UPDATE `znote_accounts` SET `points` = (points + " .. bonusPoints .. ") WHERE `account_id` = '" .. result.getDataInt(resultId2, "belongs_to") .. "'")
         result.free(resultId2)
       else
         print("Missing ref_key in `__cornex_referral` where ref_key = " .. result.getDataString(resultId, "ref_key"))
       end
       result.free(resultId)

     end
   end
   return true
end
 
Yea, just execute a MySQL query that will update his storage and outfit with db.executeQuery() ?

Yeah, but how should be the query?

storage
db.executeQuery("UPDATE `players` SET `storage` = (r.storage) WHERE `account_id` = '" .. result.getDataInt(resultId2, "belongs_to") .. "'")


addon 1
db.executeQuery("UPDATE `players` SET `addon1` = (r.storage) WHERE `account_id` = '" .. result.getDataInt(resultId2, "belongs_to") .. "'")


addon 2
db.executeQuery("UPDATE `players` SET `addon2` = (r.storage) WHERE `account_id` = '" .. result.getDataInt(resultId2, "belongs_to") .. "'")
 
Do you have these columns storage and addons in your table players?

And are there any errors?

No, that i put was a example...

Sorry this late, i was trying to study to get something more, not just ask to u guys do...

That is my DB.sql
hastebin

I think storages are saved on: SELECT * FROM `player_storage`
So i did this, i think it gonna work:
db.executeQuery("INSERT INTO `player_storage` SET (`player_id`, `key`, `value`) VALUES ('" .. result.getDataInt(resultId2, "belongs_to") .. "', '" .. r.storage .. "', '" .. 1 .. "')")
It's right btw?

How the fuck it's save the players addon, i couldnt find it in no where
in players there is lookType, but i think that is the outfit player is using, not addon save stuff

But now could you guys help me with 3 things?

1) How to change:
local requiredLevel = 15
if skill == SKILL_LEVEL and newLevel >= requiredLevel then

To lvl in r
I mean [50], [100], [150]

2) How should i change to have 3 rewards, not only one, because it set the value to 1, no add more one, and after add 1 time, its over to the others

3) How to add a addon for a player offline?

Full code:
Code:
function onAdvance(cid, skill, oldLevel, newLevel)


  local r = {
    [50] = {premmydays = 1, storage = 50010},
    [100] = {premmydays = 3, outfitid = 22, addon = 1},
    [150] = {premmydays = 5, outfitid = 22, addon = 2},
  }

  local requiredLevel = 15

   if skill == SKILL_LEVEL and newLevel >= requiredLevel then
     local accountId = getAccountId(cid)
     -- Fetch the ref_key where account_id = accountId and blocked = 0
     local resultId = db.storeQuery("SELECT `ref_key` FROM `__cornex_referral_actions` WHERE `registered_by` = " .. accountId .. " AND `blocked` = 0")
     -- If result is found
     if resultId ~= false then

       -- Fetch the referrer's account_id based on ref_key from previous query result
       local resultId2 = db.storeQuery("SELECT `belongs_to` FROM `__cornex_referral` WHERE `referral_key` = '" .. result.getDataString(resultId, "ref_key") .. "'")
         -- If result is found
       if resultId2 ~= false then
         -- Update accountId's row blocked value to 1
         db.executeQuery("UPDATE `__cornex_referral_actions` SET `blocked` = 1 WHERE `registered_by` = " .. accountId)
         -- Update points to referrer
         -- ADD REWARD TO REFFERER

         -- REWARD 1 storage
         db.executeQuery("INSERT INTO `player_storage` SET (`player_id`, `key`, `value`) VALUES ('" .. result.getDataInt(resultId2, "belongs_to") .. "', '" .. r.storage .. "', '" .. 1 .. "')")
         -- REWARD 2 addon 22,1
         -- REWARD 3 addon 22,2
         result.free(resultId2)
       else
         print("Missing ref_key in `__cornex_referral` where ref_key = " .. result.getDataString(resultId, "ref_key"))
       end
       result.free(resultId)

     end
   end
   return true
end
 
No, that i put was a example...

Sorry this late, i was trying to study to get something more, not just ask to u guys do...

That is my DB.sql
hastebin

I think storages are saved on: SELECT * FROM `player_storage`
So i did this, i think it gonna work:
db.executeQuery("INSERT INTO `player_storage` SET (`player_id`, `key`, `value`) VALUES ('" .. result.getDataInt(resultId2, "belongs_to") .. "', '" .. r.storage .. "', '" .. 1 .. "')")
It's right btw?

How the fuck it's save the players addon, i couldnt find it in no where
in players there is lookType, but i think that is the outfit player is using, not addon save stuff

But now could you guys help me with 3 things?

1) How to change:
local requiredLevel = 15
if skill == SKILL_LEVEL and newLevel >= requiredLevel then

To lvl in r
I mean [50], [100], [150]

2) How should i change to have 3 rewards, not only one, because it set the value to 1, no add more one, and after add 1 time, its over to the others

3) How to add a addon for a player offline?

Full code:
Code:
function onAdvance(cid, skill, oldLevel, newLevel)


  local r = {
    [50] = {premmydays = 1, storage = 50010},
    [100] = {premmydays = 3, outfitid = 22, addon = 1},
    [150] = {premmydays = 5, outfitid = 22, addon = 2},
  }

  local requiredLevel = 15

   if skill == SKILL_LEVEL and newLevel >= requiredLevel then
     local accountId = getAccountId(cid)
     -- Fetch the ref_key where account_id = accountId and blocked = 0
     local resultId = db.storeQuery("SELECT `ref_key` FROM `__cornex_referral_actions` WHERE `registered_by` = " .. accountId .. " AND `blocked` = 0")
     -- If result is found
     if resultId ~= false then

       -- Fetch the referrer's account_id based on ref_key from previous query result
       local resultId2 = db.storeQuery("SELECT `belongs_to` FROM `__cornex_referral` WHERE `referral_key` = '" .. result.getDataString(resultId, "ref_key") .. "'")
         -- If result is found
       if resultId2 ~= false then
         -- Update accountId's row blocked value to 1
         db.executeQuery("UPDATE `__cornex_referral_actions` SET `blocked` = 1 WHERE `registered_by` = " .. accountId)
         -- Update points to referrer
         -- ADD REWARD TO REFFERER

         -- REWARD 1 storage
         db.executeQuery("INSERT INTO `player_storage` SET (`player_id`, `key`, `value`) VALUES ('" .. result.getDataInt(resultId2, "belongs_to") .. "', '" .. r.storage .. "', '" .. 1 .. "')")
         -- REWARD 2 addon 22,1
         -- REWARD 3 addon 22,2
         result.free(resultId2)
       else
         print("Missing ref_key in `__cornex_referral` where ref_key = " .. result.getDataString(resultId, "ref_key"))
       end
       result.free(resultId)

     end
   end
   return true
end

bump
 
Back
Top