I realize there are several ways to "check" for afk users (mouse click, etc). My question is what combination of checks is the most efficient to run while still having the AFK function working accurately. By "efficient" i mean that it wont lag or slow down the game because its running a trigger every .05 seconds.
Just wondering if anyone had an idea of the most efficient combination of checks to run which wont slow down the game and is still accurate.
You can use a condition that checks the apm of any player. I would then maybe have a loop that checks to make sure the apm stays 0 for say 30 sec, then kick the player or whatever action.
Well.... Maybe make a trigger that fires when a player moves his mouse. Each time he moves his mouse a Timer Integer Variable would Get set to zero and a while loop would be enabled until the mouse is moved again. While the mouse is not moving that while loop would be adding every second a value of 1 (representing the time the player hasn't moved his mouse) At 300 seconds kick the player..
If i was you, first off, i would try to think of what a playing player in your map always does. There is no perfect way of detecting AFK players, it depends on the map and how its played.
Its very unlikely that a player doesnt press a mouse button or keyboard key for 30 seconds if hes in the game.
Trigger 2:
afktimerexpiresEventsTimer-AnyTimerexpiresLocalVariablesConditionsActionsPlayerGroup-Pickeachplayerin(ActivePlayers)anddo(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(Triggeringtimer)==afktimer[(Pickedplayer)]ThenDebug-Display(Combine((Nameofplayer(Pickedplayer))," is afk!"))asdebugoutputusingType1,andDodisplayitinthegamewindowGeneral-BreakElse
You dont need any periodic events or loops. Just restart a timer once a player does any action. You can optimize the system basically by changing the events for the timer reset trigger.
I do not recommend using events like "Mouse Moved", since it will trigger very often.
By "efficient" i mean that it wont lag or slow down the game because its running a trigger every .05 seconds.
Run the trigger at map startup (or whenever the gameplay actually starts) and have no other events. In actions, use a Repeat Forever loop with a wait action within the loop and after your trigger's actions. This will get around the problem of rapid event calls causing lag.
For a hero map, which I assume this is, there's an easy solution.
Make a behaviour. Call it "AFK Aura" or something. Give it a period of 1 sec and disable it with validators if the unit has orders.
Now make a new behaviour called "AFK Timer" or something. Set the duration to 5min and flag it as hidden. Under "remove" use the "unit has orders" validator.
Now make an effect which applies the AFK Timer to source unit, and strap that into the periodic of AFK Aura.
Finally, make a dummy effect called "Player is AFK". Put this into the "final" field of AFK Timer.
Now make a trigger with the event "unit uses effect", with "Player is AFK" as the effect.
Sorted. No lag. Zero.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I realize there are several ways to "check" for afk users (mouse click, etc). My question is what combination of checks is the most efficient to run while still having the AFK function working accurately. By "efficient" i mean that it wont lag or slow down the game because its running a trigger every .05 seconds.
Just wondering if anyone had an idea of the most efficient combination of checks to run which wont slow down the game and is still accurate.
Thanks in advance. Hope that makes sense.
You can use a condition that checks the apm of any player. I would then maybe have a loop that checks to make sure the apm stays 0 for say 30 sec, then kick the player or whatever action.
@hobbidude: Go
Well.... Maybe make a trigger that fires when a player moves his mouse. Each time he moves his mouse a Timer Integer Variable would Get set to zero and a while loop would be enabled until the mouse is moved again. While the mouse is not moving that while loop would be adding every second a value of 1 (representing the time the player hasn't moved his mouse) At 300 seconds kick the player..
use an action definition with create thread.
If i was you, first off, i would try to think of what a playing player in your map always does. There is no perfect way of detecting AFK players, it depends on the map and how its played.
However, in general i would go for this approach:
Trigger 1:
Its very unlikely that a player doesnt press a mouse button or keyboard key for 30 seconds if hes in the game.
Trigger 2:
You dont need any periodic events or loops. Just restart a timer once a player does any action. You can optimize the system basically by changing the events for the timer reset trigger. I do not recommend using events like "Mouse Moved", since it will trigger very often.
Run the trigger at map startup (or whenever the gameplay actually starts) and have no other events. In actions, use a Repeat Forever loop with a wait action within the loop and after your trigger's actions. This will get around the problem of rapid event calls causing lag.
Depends on the game.
For a hero map, which I assume this is, there's an easy solution.
Make a behaviour. Call it "AFK Aura" or something. Give it a period of 1 sec and disable it with validators if the unit has orders.
Now make a new behaviour called "AFK Timer" or something. Set the duration to 5min and flag it as hidden. Under "remove" use the "unit has orders" validator.
Now make an effect which applies the AFK Timer to source unit, and strap that into the periodic of AFK Aura.
Finally, make a dummy effect called "Player is AFK". Put this into the "final" field of AFK Timer.
Now make a trigger with the event "unit uses effect", with "Player is AFK" as the effect.
Sorted. No lag. Zero.