Trance Posted June 12, 2018 Share Posted June 12, 2018 Hi! I'm currently writing scripts for some timed events. Some attach to a randomly chosen player. I use this, to see which players are available: local players = {Server():getOnlinePlayers()} The script(s) and everything works fine, but if a player that was chosen logs off, the event may break (stop). So I have to check if a player is still online at some point and handle this. I couldn't find any information about this. I found that this exists: server:isOnline(factionIndex) But I wasn't able to find any documentation about 'isOnline'. I was experimenting a lot, tried variations of 'isOnline' calls....no luck. How do I check if a specific player is (still) online? Link to comment Share on other sites More sharing options...
Hammelpilaw Posted June 12, 2018 Share Posted June 12, 2018 Well didnt you answer the question by yourself? ;) Server():isOnline(player.index) This should return true if player is online. Or did I misunderstand the question? Link to comment Share on other sites More sharing options...
Trance Posted June 13, 2018 Author Share Posted June 13, 2018 Thanks for your answer! Here is a (shortened, debug) example of my code, i changed (included) the red part now, and it works as expected: for a, p in ipairs(players) do playercount = playercount + 1 print(a .. " " .. p.name) if Server():isOnline(p.index) then print("online") else print("offline") end end I didn't write the red part before and was thinking the player object is enough, but the isOnline() function requires an index and not a player object (I guess). After your answer it was clear! It'd be more logical for me, if it accepts a player object (too) but ok, this is the way! Thanks again! Trance Link to comment Share on other sites More sharing options...
TinchoX Posted July 2, 2018 Share Posted July 2, 2018 Uhm... tried pressing (And holding) F1 while playing online in a server yet? ::) Link to comment Share on other sites More sharing options...
Hammelpilaw Posted July 2, 2018 Share Posted July 2, 2018 Uhm... tried pressing (And holding) F1 while playing online in a server yet? ::) There is no F1 ins scripting API ;) Link to comment Share on other sites More sharing options...
TinchoX Posted July 6, 2018 Share Posted July 6, 2018 Uhm... tried pressing (And holding) F1 while playing online in a server yet? ::) There is no F1 ins scripting API ;) No shit, Sherlock. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now