SHOW:
|
|
- or go back to the newest paste.
| 1 | - | /*Declared New*/ |
| 1 | + | //*Declared New*/ |
| 2 | new AFK_Timer[MAX_PLAYERS]; | |
| 3 | - | new AFK_Kick_S[MAX_PLAYERS]; |
| 3 | + | |
| 4 | ||
| 5 | new AFKTime[MAX_PLAYERS] = 0; | |
| 6 | new AFKCheck[MAX_PLAYERS]; | |
| 7 | ||
| 8 | /*Dialogs*/ | |
| 9 | #define DIALOG_AFK 11 | |
| 10 | ||
| 11 | /*Forwards*/ | |
| 12 | forward AFK_Kick(playerid); | |
| 13 | forward AFK_Bye(playerid); | |
| 14 | - | public AFK_Kick(playerid) |
| 14 | + | |
| 15 | forward Pos_Check(playerid, Float:x, Float:y, Float:z); | |
| 16 | - | 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", ""); |
| 16 | + | |
| 17 | - | AFK_Timer[playerid] = SetTimer("AFK_Bye", 20000, false);
|
| 17 | + | |
| 18 | - | return 1; |
| 18 | + | public OnPlayerSpawn(playerid) |
| 19 | {
| |
| 20 | new Float:x, Float:y, Float:z; | |
| 21 | GetPlayerPos(playerid, x, y, z); | |
| 22 | AFKCheck[playerid] = SetTimerEx("Pos_Check", 1000, true, "ifff", playerid, x, y, z);
| |
| 23 | - | format(acstring, sizeof(acstring), "{FF4500}[ANTI CHEAT]{EE0000} %s (%i){FF4500} has been kicked from server. Reason: AFK (Away From Keyboard)", GetName(playerid), playerid);
|
| 23 | + | |
| 24 | - | SendClientMessageToAll(COLOR_ORANGE, acstring); |
| 24 | + | |
| 25 | - | SetTimer("AntiCheat", 100, false);
|
| 25 | + | public Pos_Check(playerid, Float:x, Float:y, Float:z) |
| 26 | - | return 1; |
| 26 | + | |
| 27 | if(AFKTime[playerid] < 1000) | |
| 28 | {
| |
| 29 | new Float:nx, Float:ny, Float:nz; | |
| 30 | if(nx = x && ny == y && nz = z) | |
| 31 | - | if(dialogid == DIALOG_AFK) |
| 31 | + | AFKTime[playerid]++; |
| 32 | - | {
|
| 32 | + | else |
| 33 | - | if(response) |
| 33 | + | AFKTime[playerid] = 0; |
| 34 | - | {
|
| 34 | + | } |
| 35 | - | KillTimer(AFK_Timer[playerid]); |
| 35 | + | else |
| 36 | - | KillTimer(AFK_Kick_S[playerid]); |
| 36 | + | {
|
| 37 | - | } |
| 37 | + | AFK_Kick(playerid); |
| 38 | - | } |
| 38 | + | KillTimer(AFKCheck[playerid]); |
| 39 | - | return 1; |
| 39 | + | } |
| 40 | } | |
| 41 | ||
| 42 | stock AFK_Kick(playerid) | |
| 43 | {
| |
| 44 | 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", ""); | |
| 45 | AFK_Timer[playerid] = SetTimerEx("AFK_Bye", 20000, false, "i", playerid);
| |
| 46 | return 1; | |
| 47 | } | |
| 48 | ||
| 49 | public AFK_Bye(playerid) | |
| 50 | {
| |
| 51 | format(acstring, sizeof(acstring), "{FF4500}[ANTI CHEAT]{EE0000} %s (%i){FF4500} has been kicked from server. Reason: AFK (Away From Keyboard)", GetName(playerid), playerid);
| |
| 52 | SendClientMessageToAll(COLOR_ORANGE, acstring); | |
| 53 | SetTimer("AntiCheat", 100, false);
| |
| 54 | return 1; | |
| 55 | } | |
| 56 | ||
| 57 | public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) | |
| 58 | {
| |
| 59 | if(dialogid == DIALOG_AFK) | |
| 60 | {
| |
| 61 | if(response) | |
| 62 | {
| |
| 63 | KillTimer(AFK_Timer[playerid]); | |
| 64 | ||
| 65 | AFKCheck[playerid] = SetTimerEx("Pos_Check", 1000, true, "ifff", playerid, x, y, z);
| |
| 66 | } | |
| 67 | } | |
| 68 | return 1; | |
| 69 | } | |
| 70 | ||
| 71 | public OnPlayerDisconnect(playerid) | |
| 72 | {
| |
| 73 | KillTimer(AFKCheck[playerid]); | |
| 74 | } |