Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //*Declared New*/
- new AFK_Timer[MAX_PLAYERS];
- new acstring[128];
- new AFKTime[MAX_PLAYERS] = 0;
- new AFKCheck[MAX_PLAYERS];
- /*Dialogs*/
- #define DIALOG_AFK 11
- /*Forwards*/
- forward AFK_Kick(playerid);
- forward AFK_Bye(playerid);
- forward Pos_Check(playerid, Float:x, Float:y, Float:z);
- /*Publics*/
- public OnPlayerSpawn(playerid)
- {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- AFKCheck[playerid] = SetTimerEx("Pos_Check", 1000, true, "ifff", playerid, x, y, z);
- }
- public Pos_Check(playerid, Float:x, Float:y, Float:z)
- {
- if(AFKTime[playerid] < 1000)
- {
- new Float:nx, Float:ny, Float:nz;
- if(nx = x && ny == y && nz = z)
- AFKTime[playerid]++;
- else
- AFKTime[playerid] = 0;
- }
- else
- {
- AFK_Kick(playerid);
- KillTimer(AFKCheck[playerid]);
- }
- }
- stock AFK_Kick(playerid)
- {
- ShowPlayerDialog(playerid, DIALOG_AFK, DIALOG_STYLE_MSGBOX, "Are you here ?", "This system is checking if you are AFK.\nYou will see this message if you are in-active for 1 minute.\nYou have 20 seconds to press the continue button.", "Continue", "");
- AFK_Timer[playerid] = SetTimerEx("AFK_Bye", 20000, false, "i", playerid);
- return 1;
- }
- public AFK_Bye(playerid)
- {
- format(acstring, sizeof(acstring), "{FF4500}[ANTI CHEAT]{EE0000} %s (%i){FF4500} has been kicked from server. Reason: AFK (Away From Keyboard)", GetName(playerid), playerid);
- SendClientMessageToAll(COLOR_ORANGE, acstring);
- SetTimer("AntiCheat", 100, false);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_AFK)
- {
- if(response)
- {
- KillTimer(AFK_Timer[playerid]);
- AFKCheck[playerid] = SetTimerEx("Pos_Check", 1000, true, "ifff", playerid, x, y, z);
- }
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- KillTimer(AFKCheck[playerid]);
- }
Advertisement
Add Comment
Please, Sign In to add comment