WPNiGGa

[FS] Sistema de AFK

Mar 23rd, 2014
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.76 KB | None | 0 0
  1.                                         //////////////////////////////////////////////////////////////////////////
  2.                                         //                                      [FilterScript] Sistema de AFK                                           //
  3.                                         //                                                                      //
  4.                                         //////////////////////////////////////////////////////////////////////////
  5.                                         //                          Informações do projeto                      //
  6.                                         //                                                                      //
  7.                                         // - Nome do projeto: Sistema de AFK                                    //
  8.                                         // - Autor do projeto: WPNiGGa aka n0tt_                                //
  9.                                         // - Versão do projeto: 1.1b                                            //
  10.                                         // - Data de criação: 23/03/2014                                        //
  11.                                         // - Ultima edição: 23/03/2014                                          //
  12.                                         // - Changelog: http://forum.sa-mp.com/showthread.php?p=2964218         //
  13.                                         // - Helpers: Wiki SA-MP & Forum SA-MP                                                                  //
  14.                                         // - Tempo de desenvolvimento da fase 1.0b: 1:30h.                                              // 
  15.                                         //////////////////////////////////////////////////////////////////////////
  16.                                         //                          Notas do autor                              //
  17.                                         //                                                                      //
  18.                                         // - Este projeto já foi testado IN-Game;                                                              //
  19.                                         // - Não foram encontrados quaisquer bugs;                              //
  20.                                         // - Não fazer mirrors do projeto;                                      //
  21.                                         // - Não retirar os créditos;                                                 //
  22.                                         // - Não publicar noutros foruns/sites sem o meu concentimento.         //
  23.                                         //////////////////////////////////////////////////////////////////////////
  24.  
  25. #include        <a_samp>
  26. #include    <zcmd>
  27.  
  28. #define COLOR_BLUE  0x1E90FFAA
  29. #define COLOR_RED       0xA10000AA
  30. #define TempoKick 30 //em minutos!
  31.  
  32. #if defined FILTERSCRIPT
  33.  
  34. #else
  35.  
  36. #endif
  37.  
  38. new PlayerAFK[MAX_PLAYERS];
  39. new String[100];
  40. new Float: PlayerPos[4][MAX_PLAYERS];
  41. new Weapon[13][2];
  42. new Float: PosAfk[MAX_PLAYERS][6];
  43. new TempoAFK[MAX_PLAYERS];
  44. new AFKKick[MAX_PLAYERS];
  45. new Interior[MAX_PLAYERS];
  46. new world[MAX_PLAYERS];
  47.  
  48. forward KickPlayer(playerid);
  49. public KickPlayer(playerid)
  50. {
  51.         Kick(playerid);
  52.         return 1;
  53. }
  54.  
  55. forward Atualizar(playerid);
  56. public Atualizar(playerid)
  57. {
  58.     SetTimerEx("Atualizar", 1000, false, "i", playerid);
  59.     if(PlayerAFK[playerid] != 1)
  60.     {
  61.             GetPlayerPos(playerid, PosAfk[playerid][0], PosAfk[playerid][1], PosAfk[playerid][2]);
  62.             if(PosAfk[playerid][0] != PosAfk[playerid][3] && PosAfk[playerid][1] != PosAfk[playerid][4] && PosAfk[playerid][2] != PosAfk[playerid][5])
  63.             {
  64.                 TempoAFK[playerid] = 0;
  65.                 PosAfk[playerid][3] = PosAfk[playerid][0];
  66.                 PosAfk[playerid][4] = PosAfk[playerid][1];
  67.                 PosAfk[playerid][5] = PosAfk[playerid][2];
  68.             }
  69.             else
  70.             {
  71.                 TempoAFK[playerid]++;
  72.                 if(60*2 == TempoAFK[playerid])
  73.                 {
  74.                     PlayerAFK[playerid] = 1;
  75.  
  76.                     GetPlayerPos(playerid, PlayerPos[0][playerid], PlayerPos[1][playerid], PlayerPos[2][playerid]);
  77.                     GetPlayerFacingAngle(playerid, PlayerPos[3][playerid]);
  78.                     Interior[playerid] = GetPlayerInterior(playerid);
  79.                    
  80.  
  81.                     TogglePlayerControllable(playerid, 0);
  82.  
  83.                     for(new i = 0; i < 13; i++)
  84.                         GetPlayerWeaponData(playerid, i, Weapon[i][0], Weapon[i][1]);
  85.                        
  86.                     ResetPlayerWeapons(playerid);
  87.  
  88.                     new rand = random(100) - random(10);
  89.                     SetPlayerPos(playerid, -1079.99+rand, 1061.58, 1343.04);
  90.                     SetPlayerInterior(playerid, 10);
  91.                    
  92.                     format(String, sizeof(String), "|| INFO || O %s (id: %i) está agora AFK!", Name(playerid), playerid);
  93.                     SendClientMessageToAll(COLOR_BLUE, String);
  94.                     SendClientMessage(playerid, COLOR_BLUE, "|| INFO || Usa /afk para voltares!");
  95.                     new mul = 60*TempoKick;
  96.                     mul = mul -= 120; // Retira os dois minutos que o player já estava AFK
  97.                     AFKKick[playerid] = gettime() + mul;
  98.                 }
  99.             }
  100.     }
  101.     else
  102.     {
  103.         if(gettime() >= AFKKick[playerid])
  104.         {
  105.             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);
  106.             SendClientMessageToAll(COLOR_RED, String);
  107.             SendClientMessage(playerid, COLOR_RED, "||INFO [KICK] Foste de kick por estares AFK à mais de 30 minutos.");
  108.             SetTimerEx("KickPlayer", 1000, false, "i", playerid);
  109.         }
  110.     }
  111.     return 1;
  112. }
  113.  
  114. CMD:afk(playerid)
  115. {
  116.         if(PlayerAFK[playerid] != 1)
  117.         {
  118.                 PlayerAFK[playerid] = 1;
  119.  
  120.                 GetPlayerPos(playerid, PlayerPos[0][playerid], PlayerPos[1][playerid], PlayerPos[2][playerid]);
  121.                 GetPlayerFacingAngle(playerid, PlayerPos[3][playerid]);
  122.                 Interior[playerid] = GetPlayerInterior(playerid);
  123.         world[playerid] = GetPlayeVirtualrWorld(playerid);
  124.                 TogglePlayerControllable(playerid, 0);
  125.  
  126.                 for(new i = 0; i < 13; i++)
  127.                         GetPlayerWeaponData(playerid, i, Weapon[i][0], Weapon[i][1]);
  128.                        
  129.                 ResetPlayerWeapons(playerid);
  130.  
  131.                 new rand = random(100) - random(10);
  132.                 SetPlayerVirtualWorld(playerid, 69);
  133.                 SetPlayerPos(playerid, -1079.99+rand, 1061.58, 1343.04);
  134.                 SetPlayerInterior(playerid, 10);
  135.  
  136.                 format(String, sizeof(String), "|| INFO || O %s (id: %i) está agora AFK!", Name(playerid), playerid);
  137.                 SendClientMessageToAll(COLOR_BLUE, String);
  138.                 SendClientMessage(playerid, COLOR_BLUE, "|| INFO || Usa /afk para voltares!");
  139.                 new mul = 60*TempoKick;
  140.                 AFKKick[playerid] = gettime() + mul;
  141.         }
  142.         else
  143.         {
  144.             PlayerAFK[playerid] = 0;
  145.  
  146.             SetPlayerPos(playerid, PlayerPos[0][playerid], PlayerPos[1][playerid], PlayerPos[2][playerid]);
  147.             SetPlayerFacingAngle(playerid, PlayerPos[3][playerid]);
  148.             SetPlayerInterior(playerid, Interior[playerid]);
  149.         SetPlayerVirtualWorld(playerid, world[playerid]);
  150.             TogglePlayerControllable(playerid, 1);
  151.  
  152.             ResetPlayerWeapons(playerid);
  153.  
  154.             for(new i = 0; i < 13; i++)
  155.                     GivePlayerWeapon(playerid, Weapon[i][0], Weapon[i][1]);
  156.  
  157.             format(String, sizeof(String), "|| INFO || O %s (id: %i) está de volta!", Name(playerid), playerid);
  158.             SendClientMessageToAll(COLOR_BLUE, String);
  159.         }
  160.         return 1;
  161. }
  162.  
  163. CMD:playersafk(playerid)
  164. {
  165.         new AFK, pString[200], list[200];
  166.         for(new i = 0; i < MAX_PLAYERS; i++)
  167.             {
  168.                 if(IsPlayerConnected(i))
  169.                     {
  170.                         if(PlayerAFK[i] == 1)
  171.                             {
  172.                                 format(pString, sizeof(pString), " %s (id: %d)\n", Name(i), i);
  173.                                 strcat(list, pString);
  174.                                 AFK++;
  175.                                                 }
  176.                                 }
  177.                 }
  178.         SendClientMessage(playerid, COLOR_BLUE, "--== [ PLAYERS AFK ] ==--");
  179.         if(AFK == 0) return SendClientMessage(playerid, COLOR_BLUE, "Nenhum player AFK!");
  180.  
  181.         SendClientMessage(playerid, COLOR_BLUE, list);
  182.  
  183.         SendClientMessage(playerid, COLOR_BLUE, "--=====================--");
  184.         return 1;
  185. }
  186.  
  187. public OnPlayerSpawn(playerid)
  188. {
  189.         SetTimerEx("Atualizar", 1000, false, "i", playerid);
  190.         return 1;
  191. }
  192.  
  193. stock Name(playerid)
  194. {
  195.         new nome[MAX_PLAYER_NAME+1];
  196.         GetPlayerName(playerid, nome, sizeof(nome));
  197.         return nome;
  198. }
Add Comment
Please, Sign In to add comment