Shawak
Intermediate OT User
Hello all!
Here a usefull function: getCurrentPlayers().
To add it go to your data/global.lua or your data/lib/function.lua and add:
Example:
I hope you like it! ^_^
Regards,
Shawak
Here a usefull function: getCurrentPlayers().
To add it go to your data/global.lua or your data/lib/function.lua and add:
Lua:
function getCurrentPlayers() -- by Shawak + Colandus
local db_player = db.getResult("SELECT `name` FROM `players` ORDER BY `name` ASC;")
local players = {}
if (db_player:getID() ~= -1) then
repeat
table.insert(players, db_player:getDataString("name"))
until not db_player:next()
end
db_player:free()
return players
end
Example:
Lua:
local players = getCurrentPlayers()
print(">> The server have "..#players.." players.")
for i = 1, #players do
print("> "..players[i])
end
I hope you like it! ^_^
Regards,
Shawak
Last edited: