SHOW:
|
|
- or go back to the newest paste.
| 1 | /*______________________________________________________________________________________________________ | |
| 2 | ||
| 3 | BRASIL PLAY START - | |
| 4 | Sistema Anti-AFK (Theus_Crazzy) | |
| 5 | ||
| 6 | _______________________________________________________________________________________________________*/ | |
| 7 | ||
| 8 | #include < a_samp > | |
| 9 | #include < YSI\y_timers > | |
| 10 | #include < zcmd > | |
| 11 | ||
| 12 | // Defines | |
| 13 | ||
| 14 | #define serverCallback:%0(%1) forward %0(%1); public %0(%1) | |
| 15 | #define COLOR_SAMP 0xACCBF1FF | |
| 16 | ||
| 17 | // Variáveis | |
| 18 | ||
| 19 | new | |
| 20 | timerAusente[MAX_PLAYERS], | |
| 21 | Float:oldPlayerPos[3][MAX_PLAYERS] | |
| 22 | ; | |
| 23 | ||
| 24 | #if defined FILTERSCRIPT | |
| 25 | ||
| 26 | public OnFilterScriptInit() | |
| 27 | {
| |
| 28 | print("\n_______________________________________________________");
| |
| 29 | print(" [FilterScript] Anti-AFK [Carregado]");
| |
| 30 | print("_______________________________________________________\n");
| |
| 31 | ||
| 32 | return true; | |
| 33 | } | |
| 34 | ||
| 35 | public OnFilterScriptExit() | |
| 36 | {
| |
| 37 | return true; | |
| 38 | } | |
| 39 | ||
| 40 | #else | |
| 41 | ||
| 42 | main() | |
| 43 | {
| |
| 44 | print("\n_______________________________________________________");
| |
| 45 | print(" [FilterScript] Anti-AFK [Carregado]");
| |
| 46 | print("_______________________________________________________\n");
| |
| 47 | } | |
| 48 | ||
| 49 | #endif | |
| 50 | ||
| 51 | ||
| 52 | // Funções | |
| 53 | ||
| 54 | - | static checkAusente(playerid) |
| 54 | + | stock checkAusente(playerid) |
| 55 | {
| |
| 56 | SetPVarInt(playerid, "timer_playerAFK", -1); | |
| 57 | if (timerAusente[playerid] != 0) SendClientMessage(playerid, COLOR_SAMP, "ANTI-AFK: Você não está mais inativo, atividade contando novamente."), timerAusente[playerid] = 0; | |
| 58 | } | |
| 59 | ||
| 60 | serverCallback:updatePlayerAFK(playerid, tempo) | |
| 61 | {
| |
| 62 | if (tempo >= 100) | |
| 63 | {
| |
| 64 | if (GetPVarInt(playerid, "timer_playerAFK") != -1) | |
| 65 | {
| |
| 66 | timerAusente[playerid] = gettime(); | |
| 67 | ||
| 68 | SendClientMessage(playerid, COLOR_SAMP, "ANTI-AFK: Você foi marcado como inativo, não está contando o tempo de atividade."); | |
| 69 | } | |
| 70 | } | |
| 71 | else | |
| 72 | {
| |
| 73 | if (GetPVarInt(playerid, "timer_playerAFK") != -1) | |
| 74 | {
| |
| 75 | tempo += 10; | |
| 76 | ||
| 77 | SetPVarInt(playerid, "timer_playerAFK", SetTimerEx("updatePlayerAFK", 60 * 1000, false, "ii", playerid, tempo));
| |
| 78 | } | |
| 79 | } | |
| 80 | } | |
| 81 | ||
| 82 | ptask updateSystem[60000] (i) | |
| 83 | {
| |
| 84 | new Float:atualPlayerPos[3][MAX_PLAYERS]; | |
| 85 | ||
| 86 | GetPlayerPos(i, atualPlayerPos[0][i], atualPlayerPos[1][i], atualPlayerPos[2][i]); | |
| 87 | if (oldPlayerPos[0][i] == atualPlayerPos[0][i] && oldPlayerPos[1][i] == atualPlayerPos[1][i] && oldPlayerPos[2][i] == atualPlayerPos[2][i]) | |
| 88 | {
| |
| 89 | if (GetPVarInt(i, "timer_playerAFK") == -1) | |
| 90 | SetPVarInt(i, "timer_playerAFK", SetTimerEx("updatePlayerAFK", 1000, false, "ii", i, 0));
| |
| 91 | } | |
| 92 | else | |
| 93 | {
| |
| 94 | oldPlayerPos[0][i] = atualPlayerPos[0][i]; | |
| 95 | oldPlayerPos[1][i] = atualPlayerPos[1][i]; | |
| 96 | oldPlayerPos[2][i] = atualPlayerPos[2][i]; | |
| 97 | ||
| 98 | SetPVarInt(i, "timer_playerAFK", -1); | |
| 99 | if (timerAusente[i] != 0) SendClientMessage(i, COLOR_SAMP, "ANTI-AFK: Você não está mais inativo, atividade contando novamente."), timerAusente[i] = 0; | |
| 100 | } | |
| 101 | return true; | |
| 102 | } | |
| 103 | ||
| 104 | public OnPlayerCommandPerformed(playerid, cmdtext[], success) | |
| 105 | {
| |
| 106 | checkAusente(playerid); | |
| 107 | ||
| 108 | return 1; | |
| 109 | } | |
| 110 | ||
| 111 | public OnPlayerCommandReceived(playerid, cmdtext[]) | |
| 112 | {
| |
| 113 | checkAusente(playerid); | |
| 114 | ||
| 115 | return 0; | |
| 116 | } | |
| 117 | ||
| 118 | public OnPlayerText(playerid, text[]) | |
| 119 | {
| |
| 120 | checkAusente(playerid); | |
| 121 | ||
| 122 | return 0; | |
| 123 | } | |
| 124 | ||
| 125 | public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) | |
| 126 | {
| |
| 127 | checkAusente(playerid); | |
| 128 | ||
| 129 | return 1; | |
| 130 | } |