I want to make an anti-afk feature in my map that will do the following:
If a player makes no clicks or keyboard inputs for 5 minutes, a dialogue box will come up with the following:
"Are you AFK?"
The only clickable option will be "No". If the player does not click "No" within 2 minutes, they will be removed from the game and counted as a leaver.
What is the best way to go about implementing this?
just give a txt msg warning for the player who is detected afk, when he sees the warning, he will click or something if he isn't afk. if he is, then it wil kick em
I have it set to afk= 10secs of no clicking or key presses
after the 10 secs, an alert appears and they have another 10 seconds to click or button press before they are removed
-works for only player 1 and 2, but easily expands for more-
since only 1 unit is controlled i would choose a more effective way. just save the units position as custom value and check if it is changing over time. i think you can tell for sure that someone is afk if the hero unit hasnt moved for 5 minutes.
Unit movement isnt a very efficient way to validate if a player is currently playing, for example players may use the patrol command to abuse the system.
In general, an anti afk system is just a timer. When a specific event happens, you restart the timer. Once it expires, kick the player from the game or do whatever you need. Its not really possible to give you a perfect example because it depends on your project what type of events work best.
While players do control only one unit, it can die and it can take up to a minute for it to respawn (late game). My question really is, what can I do to detect afk?
if there is a period where players passivly watch the game your best bet is to check the camera target, save it and check again. if it doesn't change the chance of him being afk is quite high. you can do that in your game loop, no event needed.
you could combine it with a mouse event trigger, if the camera target doesn't change for a certain time, turn on your mouse event trigger for this player and reset your counter and turn it off again if it fires. this will have no impact on performance at all.
I am trying a modified version of the trigger provided by joey101d. Only issue is figuring out a way to test it. In one version of a multiplayer match, it kicked every player.
I want to make an anti-afk feature in my map that will do the following:
If a player makes no clicks or keyboard inputs for 5 minutes, a dialogue box will come up with the following: "Are you AFK?" The only clickable option will be "No". If the player does not click "No" within 2 minutes, they will be removed from the game and counted as a leaver.
What is the best way to go about implementing this?
@Stormahawk: Go
depends on your map. do you already have keyboard and click events registered as events? do you control only one unit? etc
@FunkyUserName: Go
You only control one unit, and no, I don't have registered clicks or keyboard events.
this is a lot simpler than making a dialog imo.
just give a txt msg warning for the player who is detected afk, when he sees the warning, he will click or something if he isn't afk. if he is, then it wil kick em
I have it set to afk= 10secs of no clicking or key presses after the 10 secs, an alert appears and they have another 10 seconds to click or button press before they are removed
-works for only player 1 and 2, but easily expands for more-
@joey101d: Go
since only 1 unit is controlled i would choose a more effective way. just save the units position as custom value and check if it is changing over time. i think you can tell for sure that someone is afk if the hero unit hasnt moved for 5 minutes.
Unit movement isnt a very efficient way to validate if a player is currently playing, for example players may use the patrol command to abuse the system.
In general, an anti afk system is just a timer. When a specific event happens, you restart the timer. Once it expires, kick the player from the game or do whatever you need. Its not really possible to give you a perfect example because it depends on your project what type of events work best.
@FunkyUserName: Go
While players do control only one unit, it can die and it can take up to a minute for it to respawn (late game). My question really is, what can I do to detect afk?
@Stormahawk: Go
if there is a period where players passivly watch the game your best bet is to check the camera target, save it and check again. if it doesn't change the chance of him being afk is quite high. you can do that in your game loop, no event needed.
you could combine it with a mouse event trigger, if the camera target doesn't change for a certain time, turn on your mouse event trigger for this player and reset your counter and turn it off again if it fires. this will have no impact on performance at all.
I am trying a modified version of the trigger provided by joey101d. Only issue is figuring out a way to test it. In one version of a multiplayer match, it kicked every player.
test? as in see if it fires?
event: trigger X fires
action : display txt message: "trigger has fired" for all players
Seems to work now. After some further testing, I will post my modified version here.