As the title says, the player.getLastTimeOnline() method seems to only work for currently online players, i.e. if called on a username of another player not online it doesn't return anything. (We tried it on a dedicated server and a LAN game)
player.getLastTimeOnline() seems to only work for currently online players
-
- English
- Minotorious
- Thread is marked as Resolved.
-
-
I have not used player.getLastTimeOnline() so far, but I imagined a solution!
It is possible to access the World-Database to fetch data from all players.JavaI hope this could help you out!
-
Yes i used the sql query too instead but the java method should be corrected if it doesn't work
-
Upps, my bad! Now I understood! It's a bug, not a feature!
-
from my understanding the problem with .getLastTimeOnline() is that it is a method defined under the Player object which object is only defined for players currently online. Thus the method cannot be used to view players that are not online which is its whole purpose
PS: it is a "feature" not a feature as people call them
-
...or with some other words:
-
It's indeed a trap I have to admit the name of this function may be misleading. Actually it is supposed to return the timestamp of the date when the player was previously online (i.e. if I play on a server on March 1st, then take a break and join the server on April 10th again, this method will return the timestamp of the 1st of March).
As you suspected, the server.getPlayer() functions only work with online player, so this method isn't accessible for offline players. I'm not sure if it makes sense to cover offline players by these methods as well (since most funtions of the Player object won't make much sense for offline players)... we'll have to think about that
The old Lua API provided a function to get some player information from the database, maybe we will add this function to the new API as well. Otherwise quering the database, as mentioned by @Machete would do the trick (actually a "getPlayerInformation()" function would do exactly the same^^) -
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!