Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////
- // [FilterScript] Sistema de AFK //
- // //
- //////////////////////////////////////////////////////////////////////////
- // Informações do projeto //
- // //
- // - Nome do projeto: Sistema de AFK //
- // - Autor do projeto: WPNiGGa aka n0tt_ //
- // - Versão do projeto: 1.1b //
- // - Data de criação: 23/03/2014 //
- // - Ultima edição: 23/03/2014 //
- // - Changelog: http://forum.sa-mp.com/showthread.php?p=2964218 //
- // - Helpers: Wiki SA-MP & Forum SA-MP //
- // - Tempo de desenvolvimento da fase 1.0b: 1:30h. //
- //////////////////////////////////////////////////////////////////////////
- // Notas do autor //
- // //
- // - Este projeto já foi testado IN-Game; //
- // - Não foram encontrados quaisquer bugs; //
- // - Não fazer mirrors do projeto; //
- // - Não retirar os créditos; //
- // - Não publicar noutros foruns/sites sem o meu concentimento. //
- //////////////////////////////////////////////////////////////////////////
- #include <a_samp>
- #include <zcmd>
- #define COLOR_BLUE 0x1E90FFAA
- #define COLOR_RED 0xA10000AA
- #define TempoKick 30 //em minutos!
- #if defined FILTERSCRIPT
- #else
- #endif
- new PlayerAFK[MAX_PLAYERS];
- new String[100];
- new Float: PlayerPos[4][MAX_PLAYERS];
- new Weapon[13][2];
- new Float: PosAfk[MAX_PLAYERS][6];
- new TempoAFK[MAX_PLAYERS];
- new AFKKick[MAX_PLAYERS];
- new Interior[MAX_PLAYERS];
- new world[MAX_PLAYERS];
- forward KickPlayer(playerid);
- public KickPlayer(playerid)
- {
- Kick(playerid);
- return 1;
- }
- forward Atualizar(playerid);
- public Atualizar(playerid)
- {
- SetTimerEx("Atualizar", 1000, false, "i", playerid);
- if(PlayerAFK[playerid] != 1)
- {
- GetPlayerPos(playerid, PosAfk[playerid][0], PosAfk[playerid][1], PosAfk[playerid][2]);
- if(PosAfk[playerid][0] != PosAfk[playerid][3] && PosAfk[playerid][1] != PosAfk[playerid][4] && PosAfk[playerid][2] != PosAfk[playerid][5])
- {
- TempoAFK[playerid] = 0;
- PosAfk[playerid][3] = PosAfk[playerid][0];
- PosAfk[playerid][4] = PosAfk[playerid][1];
- PosAfk[playerid][5] = PosAfk[playerid][2];
- }
- else
- {
- TempoAFK[playerid]++;
- if(60*2 == TempoAFK[playerid])
- {
- PlayerAFK[playerid] = 1;
- GetPlayerPos(playerid, PlayerPos[0][playerid], PlayerPos[1][playerid], PlayerPos[2][playerid]);
- GetPlayerFacingAngle(playerid, PlayerPos[3][playerid]);
- Interior[playerid] = GetPlayerInterior(playerid);
- TogglePlayerControllable(playerid, 0);
- for(new i = 0; i < 13; i++)
- GetPlayerWeaponData(playerid, i, Weapon[i][0], Weapon[i][1]);
- ResetPlayerWeapons(playerid);
- new rand = random(100) - random(10);
- SetPlayerPos(playerid, -1079.99+rand, 1061.58, 1343.04);
- SetPlayerInterior(playerid, 10);
- format(String, sizeof(String), "|| INFO || O %s (id: %i) está agora AFK!", Name(playerid), playerid);
- SendClientMessageToAll(COLOR_BLUE, String);
- SendClientMessage(playerid, COLOR_BLUE, "|| INFO || Usa /afk para voltares!");
- new mul = 60*TempoKick;
- mul = mul -= 120; // Retira os dois minutos que o player já estava AFK
- AFKKick[playerid] = gettime() + mul;
- }
- }
- }
- else
- {
- if(gettime() >= AFKKick[playerid])
- {
- format(String, sizeof(String), "|| INFO [KICK] || O player %s (id: %i) foi de kick por estar a AFK à mais de 30 minutos.", Name(playerid), playerid);
- SendClientMessageToAll(COLOR_RED, String);
- SendClientMessage(playerid, COLOR_RED, "||INFO [KICK] Foste de kick por estares AFK à mais de 30 minutos.");
- SetTimerEx("KickPlayer", 1000, false, "i", playerid);
- }
- }
- return 1;
- }
- CMD:afk(playerid)
- {
- if(PlayerAFK[playerid] != 1)
- {
- PlayerAFK[playerid] = 1;
- GetPlayerPos(playerid, PlayerPos[0][playerid], PlayerPos[1][playerid], PlayerPos[2][playerid]);
- GetPlayerFacingAngle(playerid, PlayerPos[3][playerid]);
- Interior[playerid] = GetPlayerInterior(playerid);
- world[playerid] = GetPlayeVirtualrWorld(playerid);
- TogglePlayerControllable(playerid, 0);
- for(new i = 0; i < 13; i++)
- GetPlayerWeaponData(playerid, i, Weapon[i][0], Weapon[i][1]);
- ResetPlayerWeapons(playerid);
- new rand = random(100) - random(10);
- SetPlayerVirtualWorld(playerid, 69);
- SetPlayerPos(playerid, -1079.99+rand, 1061.58, 1343.04);
- SetPlayerInterior(playerid, 10);
- format(String, sizeof(String), "|| INFO || O %s (id: %i) está agora AFK!", Name(playerid), playerid);
- SendClientMessageToAll(COLOR_BLUE, String);
- SendClientMessage(playerid, COLOR_BLUE, "|| INFO || Usa /afk para voltares!");
- new mul = 60*TempoKick;
- AFKKick[playerid] = gettime() + mul;
- }
- else
- {
- PlayerAFK[playerid] = 0;
- SetPlayerPos(playerid, PlayerPos[0][playerid], PlayerPos[1][playerid], PlayerPos[2][playerid]);
- SetPlayerFacingAngle(playerid, PlayerPos[3][playerid]);
- SetPlayerInterior(playerid, Interior[playerid]);
- SetPlayerVirtualWorld(playerid, world[playerid]);
- TogglePlayerControllable(playerid, 1);
- ResetPlayerWeapons(playerid);
- for(new i = 0; i < 13; i++)
- GivePlayerWeapon(playerid, Weapon[i][0], Weapon[i][1]);
- format(String, sizeof(String), "|| INFO || O %s (id: %i) está de volta!", Name(playerid), playerid);
- SendClientMessageToAll(COLOR_BLUE, String);
- }
- return 1;
- }
- CMD:playersafk(playerid)
- {
- new AFK, pString[200], list[200];
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(PlayerAFK[i] == 1)
- {
- format(pString, sizeof(pString), " %s (id: %d)\n", Name(i), i);
- strcat(list, pString);
- AFK++;
- }
- }
- }
- SendClientMessage(playerid, COLOR_BLUE, "--== [ PLAYERS AFK ] ==--");
- if(AFK == 0) return SendClientMessage(playerid, COLOR_BLUE, "Nenhum player AFK!");
- SendClientMessage(playerid, COLOR_BLUE, list);
- SendClientMessage(playerid, COLOR_BLUE, "--=====================--");
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SetTimerEx("Atualizar", 1000, false, "i", playerid);
- return 1;
- }
- stock Name(playerid)
- {
- new nome[MAX_PLAYER_NAME+1];
- GetPlayerName(playerid, nome, sizeof(nome));
- return nome;
- }
Add Comment
Please, Sign In to add comment