Skip to content

Where would I look if I wanted to implement a gone idle call on #0? #88

Answered by Oliver2213
NathanTech7713 asked this question in Q&A
Discussion options

You must be logged in to vote

Certainly doable, though I think you'd be better served just writing this in your database. Use a heart, task scheduler or similar mechanism if you have one. Schedule it to run every n, where n is your interval (300 seconds). Every run of your task, check connected players, and a property you add to your generic player class which keeps track of the last command time:

for i in (connected_players())
  if(time() - `i.last_command_time ! E_PROPNF => time()' > 300)
    "Call your gone idle verb here";
  endif
  yin();
endfor

In #0:do_command, before you return, update that property on the player with the current time.
That code also falls back to the current time if the prop can't be found on…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tvdijen
Comment options

Answer selected by distantorigin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants