• 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 1.X+ Function to get all players who have the higer value of storage 16200

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
Hello! I'm using tfs 1.2 and need a function to check the 5 players who have the highest value of the storage (16200), and they will receive a storage of value 16201.
Everything happens when turn on the server.
Could anyone help?
 
Solution
Hello! I'm using tfs 1.2 and need a function to check the 5 players who have the highest value of the storage (16200), and they will receive a storage of value 16201.
Everything happens when turn on the server.
Could anyone help?
Imo best way to do this is to store all five players in global array for use during session instead of changing another storage to identify who is in top 5.

Lua:
-- global.lua
top_five = {}

-- startup.lua
local resultId = db.storeQuery("SELECT `player_id` FROM `player_storage` WHERE `key` = 16200 ORDER BY `value` DESC LIMIT 5")
if resultId ~= false then
    repeat
        top_five[#top_five + 1] = result.getDataInt(resultId, "player_id")
    until not result.next(resultId)
    result.free(resultId)
end
Hello! I'm using tfs 1.2 and need a function to check the 5 players who have the highest value of the storage (16200), and they will receive a storage of value 16201.
Everything happens when turn on the server.
Could anyone help?
Imo best way to do this is to store all five players in global array for use during session instead of changing another storage to identify who is in top 5.

Lua:
-- global.lua
top_five = {}

-- startup.lua
local resultId = db.storeQuery("SELECT `player_id` FROM `player_storage` WHERE `key` = 16200 ORDER BY `value` DESC LIMIT 5")
if resultId ~= false then
    repeat
        top_five[#top_five + 1] = result.getDataInt(resultId, "player_id")
    until not result.next(resultId)
    result.free(resultId)
end
 
Solution
Back
Top