In AreaProtection, players are saved using player:getDBID(). This value matches the ID field in the table Player of the world's database. However, performing server:findPlayerByID(playerId) (where playerId is the saved value) does not return anything; nil. Is this because the player is not connected, therefore the method returns nothing? Shouldn't that method fetch the user in the World's DB instead if the player is not connected? What's the alternative, then?
server:findPlayerByID returns nil
-
- English
- LordFoobar
- Closed
A new update is now available, introducing seasons and more!
-
-
Currently server:findPlayerByID(playerid) is looking for the "regular" playerid (instead of the db id), so this method can only find players which are currently online. At the moment it is not possible to get an "offline player", but we're thinking about implementing something like that in the future. Currently you can only use server:getPlayerInformationFromDB(playername) (we will add a similar function with the next update which uses the db id instead), which returns a "PlayerInformation" object containing information about the particular player (currently these fields: position, rotation, onlineTime, lastTimeOnline, health, hunger, thirst, brokenBones, dead, fly, dbID, name).
-
Alright, that's what I guessed. So... if I understand this, LuaPlayer strictly returns an online player, currently connected to the server, while LuaPlayerInformation returns something only if the player has connected to the server at some point (online or not), am I right?
-
Alright, that's what I guessed. So... if I understand this, LuaPlayer strictly returns an online player, currently connected to the server, while LuaPlayerInformation returns something only if the player has connected to the server at some point (online or not), am I right?
Exactly
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!