Guest User

Sistema AFK [By Caio_Cartaxo]

a guest
Nov 5th, 2010
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.21 KB | None | 0 0
  1. /*
  2.         SISTEMA AFK
  3.             BY CAIO_CARTAXO
  4.                 RETIRE OS CREDITOS E PERCA SEU SERVIDOR ;***
  5.                     VISITE O BRASIL VIRTUAL LIFECITY! IP: 189.1.168.246:7805
  6.                         FORUM: WWW.BVLC.FORUMEIROS.COM
  7. */
  8.  
  9. //Includes
  10. #include <a_caio>
  11. #include <a_samp>
  12.  
  13. //Defines
  14. #define COR_VERMELHA    0xFF000096
  15. #define COR_VERDE       0x00FF0096
  16. #define COR_ROXO        0xC2A2DAAA
  17.  
  18. //Forwards
  19. forward Chute(playerid);
  20. forward Segundo();
  21.  
  22. //News
  23. new PlayerAfk[MAX_PLAYERS];
  24. new Tempo[MAX_PLAYERS];
  25. new sendername[MAX_PLAYER_NAME];
  26. new string[128];
  27. new cmd[128];
  28. new SegundoAfk[MAX_PLAYERS];
  29. new MinutoAfk[MAX_PLAYERS];
  30. new ContarSegundo;
  31.  
  32. //Publics
  33. public OnPlayerConnect(playerid)
  34. {
  35.     PlayerAfk[playerid] = 0;
  36.     SegundoAfk[playerid] = 0;
  37.     MinutoAfk[playerid] = 0;
  38.     return 1;
  39. }
  40. public OnPlayerDisconnect(playerid)
  41. {
  42.     KillTimer(Tempo[playerid]);
  43.     SegundoAfk[playerid] = 0;
  44.     MinutoAfk[playerid] = 0;
  45.     return 1;
  46. }
  47. public OnFilterScriptInit()
  48. {
  49.     print("Sistema AFK carregado!");
  50.     print("   By Caio_Cartaxo");
  51.     ContarSegundo = SetTimer("Segundo", 1000, false);
  52.     return 1;
  53. }
  54. public OnFilterScriptExit()
  55. {
  56.     KillTimer(ContarSegundo);
  57.     for(new i = 0; i < MAX_PLAYERS; i++)
  58.     {
  59.         if(IsPlayerConnected(i))
  60.         {
  61.             KillTimer(Tempo[i]);
  62.         }
  63.     }
  64.     return 1;
  65. }
  66. public Segundo()
  67. {
  68.     for(new i = 0; i < MAX_PLAYERS; i++)
  69.     {
  70.         if(IsPlayerConnected(i))
  71.         {
  72.             if(MinutoAfk[i] == 60)
  73.             {
  74.                 SegundoAfk[i] = 1;
  75.             }
  76.             else if(SegundoAfk[i] > 0)
  77.             {
  78.                 SegundoAfk[i] ++;
  79.             }
  80.         }
  81.     }
  82.     return 1;
  83. }
  84. public OnPlayerCommandText(playerid, cmdtext[])
  85. {
  86.     if(strcmp(cmd, "/afk", true) == 0)
  87.     {
  88.         if(PlayerAfk[playerid] == 0)
  89.         {
  90.             PlayerAfk[playerid] = 1;
  91.             LimparChat(playerid, 10);
  92.             SetPlayerVirtualWorld(playerid, 1);
  93.             TogglePlayerControllable(playerid, false);
  94.             GetPlayerName(playerid, sendername, sizeof(sendername));
  95.             Tempo[playerid] = SetTimerEx("Chute", 600000, false, "i", playerid);
  96.             GameTextForPlayer(playerid, "~r~voce esta ausente ~w~~n~Use /online para voltar", 10000, 3);
  97.             format(string, sizeof(string), "* %s Esta Away From Keyboard! (/afk) [By Caio_Cartaxo]", sendername);
  98.             SendClientMessageToAll(COR_ROXO, string);
  99.             printf("%s", string);
  100.             SegundoAfk[playerid] = 1;
  101.             MinutoAfk[playerid] = 0;
  102.         }
  103.         else
  104.         {
  105.             SendClientMessage(playerid, COR_VERMELHA, "Você já está AFK!");
  106.         }
  107.         return 1;
  108.     }
  109.     if(strcmp(cmd, "/online", true) == 0)
  110.     {
  111.         if(PlayerAfk[playerid] == 1)
  112.         {
  113.             PlayerAfk[playerid] = 0;
  114.             LimparChat(playerid, 10);
  115.             SetPlayerVirtualWorld(playerid, 0);
  116.             TogglePlayerControllable(playerid, true);
  117.             GetPlayerName(playerid, sendername, sizeof(sendername));
  118.             GameTextForPlayer(playerid, "~g~Voce voltou a jogar", 3000, 3);
  119.             format(string, sizeof(string), "* %s Voltou a jogar! (/online) [By Caio_Cartaxo]", sendername);
  120.             SendClientMessageToAll(COR_VERDE, string);
  121.             KillTimer(Tempo[playerid]);
  122.             printf("%s", string);
  123.             SegundoAfk[playerid] = 0;
  124.             MinutoAfk[playerid] = 0;
  125.         }
  126.         else
  127.         {
  128.             SendClientMessage(playerid, COR_VERMELHA, "Você não está AFK!");
  129.         }
  130.         return 1;
  131.     }
  132.     if (strcmp(cmdtext, "/afks", true) == 0)
  133.     {
  134.         if(IsPlayerConnected(playerid))
  135.         {
  136.             SendClientMessage(playerid, COR_ROXO, "Lista de Jogadores AFK:");
  137.             SendClientMessage(playerid, COR_VERDE, "   Sistema By Caio_Cartaxo");
  138.             for(new i = 0; i < MAX_PLAYERS; i++)
  139.             {
  140.                 if(IsPlayerConnected(i))
  141.                 {
  142.                     if(PlayerAfk[i] > 0)
  143.                     {
  144.                         GetPlayerName(i, sendername, sizeof(sendername));
  145.                         if(PlayerAfk[i] == 1)
  146.                         {
  147.                             format(string, 256, "Jogador: %s [Minutos: %d | Segundos: %d]", sendername, MinutoAfk[playerid], SegundoAfk[playerid]);
  148.                             SendClientMessage(playerid, COR_VERMELHA, string);
  149.                         }
  150.                     }
  151.                 }
  152.             }
  153.         }
  154.         return 1;
  155.     }
  156.     return 1;
  157. }
  158. public Chute(playerid)
  159. {
  160.     if(PlayerAfk[playerid] == 1)
  161.     {
  162.         GetPlayerName(playerid, sendername, sizeof(sendername));
  163.         format(string, sizeof(string), "* %s Foi chutado do servidor por ficar AFK por 10 minutos! [By Caio_Cartaxo]", sendername);
  164.         SendClientMessageToAll(COR_VERDE, string);
  165.         printf("%s", string);
  166.         Kick(playerid);
  167.     }
  168.     else { print("Este player nao esta AFK imbecil -.-"); }
  169.     return 1;
  170. }
Advertisement
Add Comment
Please, Sign In to add comment