• 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!

AAC GlobalStorage for best points

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
201
Hello, I have a question in the script.
It will check the 3 players that have the highest value of storge 16200.
After checking it will add to the highest score the storage 888999 of value 1. To the second punter the value 2 and the third punter the value 3.
Example:
Noham has 16200 value 1000 storage
Noemi has 16200 value 900 storage
Kyz has storage 16200 worth 50
The script will check and will add storage 888999 of value 1 to Noham (because it was the highest scorer).
It will add 888999 of value 2 to Noemi (second scorer).
And it will add 888999 of value 3 to Kyz (third scorer).
My question is this, how do I save the value of the 16200 storage of the 3 players in a global storage?
For example the global storage number one receives the value of 1000 (highest score)
The second global storage receives 900, and the last receives the value of 50.


Code:
local storage = 888999           
local high_value = 16200

function onUse(item)
    local score = 1
    local highscore = db.storeQuery("SELECT `player_id` FROM `player_storage` WHERE `player_storage`.`key` = '" .. high_value .. "' and value > 0 ORDER BY value DESC LIMIT 5;")
    db.query("UPDATE `player_storage` SET  `value` =  '0' WHERE `player_storage`.`key` = " .. storage .. ";")

    if result.getDataInt(highscore, "player_id") then
            local pl_id = result.getDataInt(highscore, "player_id")
  
        db.query("UPDATE `player_storage` SET  `value` =  " .. score .. " WHERE  `player_storage`.`player_id` = " .. pl_id .. " AND  `player_storage`.`key` = " .. storage .. ";")

       score = score + 1
            while(result:next(highscore)) do
                local pl_id = result.getDataInt(highscore, "player_id")
        db.query("UPDATE `player_storage` SET  `value` =  " .. score .. " WHERE  `player_storage`.`player_id` = " .. pl_id .. " AND  `player_storage`.`key` = " .. storage .. ";")
                score = score + 1
    end
end
return true
end
 
1. Why do you want to save the storage value in globalstorage value? -- this will help understand better your problem

2. not sure if this helps but: setGlobalStorageValue(888999, getPlayerStorageValue(16200))
 
Back
Top