Code share: Perfect AFK Timer (CPU friendly with excellent accuracy)
Maybe for someone this code will be usefull. I share this AFK Timer, because most of timers that already exist and "detects" - AFK - works by "PLAYER_FLAGS_CHANGED" EVENT. But it's not correct, because game detect any mouse move and keypress and then it reset afk timer.
For example, if you will move your mouse every 29 minutes or press any key (i mean ANY, for example CTRL), you will never be kicked from game World, for AFK.
As well, most timers uses "OnUpdate" event that triggers every frame, and it's not CPU efficient.
This is very simple and very CPU friendly code, that detects logout (AFK) time with perfect precision.
This code uses only ticker instead of "OnUpdate", that's why it's very CPU friendly.
Even that C_Timer.NewTicker i think a bit more expensive then "OnUpdate", it triggers a lot more rarely.
Only thing it's not tracking - combat or out of combat. But i think it's easy to implement in future.
To make this code more CPU efficient, you can change step from 1 second to 10 for example.
P.S. Thank you MunkDev for helping with code that detects keypress - http://www.wowinterface.com/forums/s...ad.php?t=52723
Haven't tested this code snippet, but at a first glance I noticed you named the frame "Frame".
Even though it's just an example, consider changing that name to something more distinguished. ;)
|All times are GMT -6. The time now is 09:57 PM.|
vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI