Originally Posted by
BrolyYO
Unless you somehow want to be tracked, and banned, this is the safest method so far, made with a timer. No matter how ugly it is (for you) if works then nothing to say about.
The method you propose is much, much easier to track by the server. Warden could potentially read the value of the lastHardwareAction global variable, but it would have no reliable way of knowing if the value it reads was written by the game or not.
Edit: This is my anti AFK hack and I have never been banned on any private server on any version, and it has always worked.
Code:
static class AntiAfk
{
#region Properties
public static bool Enabled
{
get { return ResetTimer.Enabled; }
set { ResetTimer.Enabled = value; }
}
private static readonly Timer ResetTimer = new Timer(10000);
#endregion
static AntiAfk()
{
ResetTimer.Elapsed += ResetTimerTick;
ResetTimer.Enabled = true;
}
static void ResetTimerTick(object source, ElapsedEventArgs e)
{
Status.LastHardwareAction = Status.TickCount;
}
}
Code:
static class Status
{
public static uint TickCount
{
get
{
var func =
(GetTickCountDelegate)
Marshal.GetDelegateForFunctionPointer(Locator.GetTickCount, typeof (GetTickCountDelegate));
return func();
}
}
public static uint LastHardwareAction
{
get { return (uint)Marshal.ReadInt32(Locator.LastHardwareAction); }
set { Marshal.WriteInt32(Locator.LastHardwareAction, (int) value); }
}
}