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

Lua Get player list

guiismiti

Well-Known Member
Joined
May 19, 2014
Messages
315
Solutions
3
Reaction score
68
Hi,

All I need is the function to get the list of the ids of all players of the server. I don't want the names, I just need the id numbers. I'm using TFS 0.3.6.

My purpose is to use it in login.lua. If any of the players from the same account has a certain storage value, it will also set the same storage value for the current player. This so I can store a value account wide.


Thanks in advance
 
Code:
local q = db.getResult('select id from players;')
local t = {}
if q:ID() ~= -1 then
    repeat
        table.insert(t, q:getDataInt('id'))
    until not q:next()
   q:free() --not sure about this, i don't remember
end
 
@Peonso - yea that's for getting the account of a certain player.
@Himii - yes I know it's in my database, but the size of the list is variable. It changes every time a character is created. Also, insert a list manually makes no sense when the funtion to obtain it exists.
@Darkhaos - thanks, gonna test it, not sure my distro supports it though (OTSL).
 
local query = db.getResult("SELECT `id` FROM `players`;")

But I don't know how you can handle that through lua. This shit sounded simple when I suggested it in ZnoteAAC thread, but it's probably way easier by AAC, you did what Znote sugested?
 
local query = db.getResult("SELECT `id` FROM `players`;")

But I don't know how you can handle that through lua. This shit sounded simple when I suggested it in ZnoteAAC thread, but it's probably way easier by AAC, you did what Znote sugested?

Yes I did, and that worked well. I really like that website.
Thanks for the support
 
Back
Top