Advertisement
N3to

Anti-AFK v1

Nov 6th, 2013
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.95 KB | None | 0 0
  1. /*
  2. =================================
  3.  
  4. Criado por: Neto
  5. Versão: 1.0
  6.  
  7. =================================
  8.  
  9. */
  10. #include <a_samp>
  11. #include <icmd>
  12.  
  13. #define MAX_AFKTIME (25)
  14.  
  15. forward PUpdate();
  16.  
  17. new PlayerSpawn[MAX_PLAYERS];
  18.  
  19. new bool:AFK[MAX_PLAYERS];
  20.  
  21. new Float:VidaAntes[MAX_PLAYERS];
  22.  
  23. new Text:Textdraw0[MAX_PLAYERS];
  24. new Text:Textdraw1[MAX_PLAYERS];
  25. new Text:Textdraw2[MAX_PLAYERS];
  26. new Text:Textdraw3[MAX_PLAYERS];
  27. new Text:Textdraw4[MAX_PLAYERS];
  28. new Text:Textdraw5[MAX_PLAYERS];
  29. new Text:Textdraw6[MAX_PLAYERS];
  30.  
  31. new Float:AFKNewPosX[MAX_PLAYERS],Float:AFKNewPosY[MAX_PLAYERS],Float:AFKNewPosZ[MAX_PLAYERS];
  32. new Float:AFKOldPosX[MAX_PLAYERS],Float:AFKOldPosY[MAX_PLAYERS],Float:AFKOldPosZ[MAX_PLAYERS];
  33. new AFKTime[MAX_PLAYERS];
  34.  
  35. public OnFilterScriptInit()
  36. {
  37.     print("\n--------------------------------------");
  38.     print(" Anti-AFK carregado com sucesso!");
  39.     print(" Versão: 1.0");
  40.     print(" Criado por Neto");
  41.     print("--------------------------------------\n");
  42.     SetTimer("PUpdate", 1000, 1);
  43.     for(new i=0;i<MAX_PLAYERS;i++)
  44.     {
  45.        
  46.         Textdraw0[i] = TextDrawCreate(410.000000, 155.000000, "_");
  47.         TextDrawBackgroundColor(Textdraw0[i], 255);
  48.         TextDrawFont(Textdraw0[i], 1);
  49.         TextDrawLetterSize(Textdraw0[i], 0.500000, 18.000000);
  50.         TextDrawColor(Textdraw0[i], -1);
  51.         TextDrawSetOutline(Textdraw0[i], 0);
  52.         TextDrawSetProportional(Textdraw0[i], 1);
  53.         TextDrawSetShadow(Textdraw0[i], 1);
  54.         TextDrawUseBox(Textdraw0[i], 1);
  55.         TextDrawBoxColor(Textdraw0[i], 353703423);
  56.         TextDrawTextSize(Textdraw0[i], 218.000000, 110.000000);
  57.         TextDrawSetSelectable(Textdraw0[i], 0);
  58.  
  59.         Textdraw1[i] = TextDrawCreate(400.000000, 168.000000, "_");
  60.         TextDrawBackgroundColor(Textdraw1[i], 255);
  61.         TextDrawFont(Textdraw1[i], 1);
  62.         TextDrawLetterSize(Textdraw1[i], 0.500000, 15.300001);
  63.         TextDrawColor(Textdraw1[i], -1);
  64.         TextDrawSetOutline(Textdraw1[i], 0);
  65.         TextDrawSetProportional(Textdraw1[i], 1);
  66.         TextDrawSetShadow(Textdraw1[i], 1);
  67.         TextDrawUseBox(Textdraw1[i], 1);
  68.         TextDrawBoxColor(Textdraw1[i], 656877567);
  69.         TextDrawTextSize(Textdraw1[i], 230.000000, 110.000000);
  70.         TextDrawSetSelectable(Textdraw1[i], 0);
  71.  
  72.         Textdraw2[i] = TextDrawCreate(254.000000, 166.000000, "Anti-AFK");
  73.         TextDrawBackgroundColor(Textdraw2[i], 255);
  74.         TextDrawFont(Textdraw2[i], 3);
  75.         TextDrawLetterSize(Textdraw2[i], 0.779999, 4.000000);
  76.         TextDrawColor(Textdraw2[i], -65281);
  77.         TextDrawSetOutline(Textdraw2[i], 0);
  78.         TextDrawSetProportional(Textdraw2[i], 1);
  79.         TextDrawSetShadow(Textdraw2[i], 1);
  80.         TextDrawSetSelectable(Textdraw2[i], 0);
  81.  
  82.         Textdraw3[i] = TextDrawCreate(266.000000, 207.000000, "Estas AFK!");
  83.         TextDrawBackgroundColor(Textdraw3[i], 255);
  84.         TextDrawFont(Textdraw3[i], 1);
  85.         TextDrawLetterSize(Textdraw3[i], 0.529999, 1.299999);
  86.         TextDrawColor(Textdraw3[i], -1);
  87.         TextDrawSetOutline(Textdraw3[i], 0);
  88.         TextDrawSetProportional(Textdraw3[i], 1);
  89.         TextDrawSetShadow(Textdraw3[i], 1);
  90.         TextDrawSetSelectable(Textdraw3[i], 0);
  91.  
  92.         Textdraw4[i] = TextDrawCreate(234.000000, 223.000000, "Mexe-te para nao levares kick.");
  93.         TextDrawBackgroundColor(Textdraw4[i], 255);
  94.         TextDrawFont(Textdraw4[i], 1);
  95.         TextDrawLetterSize(Textdraw4[i], 0.319999, 1.799999);
  96.         TextDrawColor(Textdraw4[i], -1);
  97.         TextDrawSetOutline(Textdraw4[i], 0);
  98.         TextDrawSetProportional(Textdraw4[i], 1);
  99.         TextDrawSetShadow(Textdraw4[i], 1);
  100.         TextDrawSetSelectable(Textdraw4[i], 0);
  101.  
  102.         Textdraw5[i] = TextDrawCreate(234.000000, 255.000000, "Seras Kickado em:");
  103.         TextDrawBackgroundColor(Textdraw5[i], 255);
  104.         TextDrawFont(Textdraw5[i], 1);
  105.         TextDrawLetterSize(Textdraw5[i], 0.389999, 2.999999);
  106.         TextDrawColor(Textdraw5[i], -1);
  107.         TextDrawSetOutline(Textdraw5[i], 0);
  108.         TextDrawSetProportional(Textdraw5[i], 1);
  109.         TextDrawSetShadow(Textdraw5[i], 1);
  110.         TextDrawSetSelectable(Textdraw5[i], 0);
  111.  
  112.         Textdraw6[i] = TextDrawCreate(357.000000, 236.000000, "0");
  113.         TextDrawBackgroundColor(Textdraw6[i], 255);
  114.         TextDrawFont(Textdraw6[i], 2);
  115.         TextDrawLetterSize(Textdraw6[i], 0.699999, 7.299999);
  116.         TextDrawColor(Textdraw6[i], -1);
  117.         TextDrawSetOutline(Textdraw6[i], 0);
  118.         TextDrawSetProportional(Textdraw6[i], 1);
  119.         TextDrawSetShadow(Textdraw6[i], 1);
  120.         TextDrawSetSelectable(Textdraw6[i], 0);
  121.     }
  122.     return 1;
  123. }
  124.  
  125. public OnFilterScriptExit()
  126. {
  127.     return 1;
  128. }
  129.  
  130. public OnPlayerSpawn(playerid)
  131. {
  132.     if(PlayerSpawn[playerid] == 0) PlayerSpawn[playerid] = 1;
  133.     return 1;
  134. }
  135.  
  136. public PUpdate()
  137. {
  138.     for(new i=0;i<MAX_PLAYERS;i++)
  139.     {
  140.        
  141.         if(AFK[i] == false)
  142.         {
  143.            
  144.             if(PlayerSpawn[i] == 1)
  145.             {
  146.                
  147.                 GetPlayerPos(i,AFKNewPosX[i],AFKNewPosY[i],AFKNewPosZ[i]);
  148.                 if(AFKNewPosX[i] == AFKOldPosX[i] && AFKNewPosY[i] == AFKOldPosY[i] && AFKNewPosZ[i] == AFKOldPosZ[i])
  149.                 {
  150.                    
  151.                     AFKTime[i]--;
  152.                     if(AFKTime[i] == 0)
  153.                     {
  154.                        
  155.                         Kick(i);
  156.                         AFKNewPosX[i]=0.0;
  157.                         AFKNewPosY[i]=0.0;
  158.                         AFKNewPosZ[i]=0.0;
  159.                         AFKOldPosX[i]=0.0;
  160.                         AFKOldPosY[i]=0.0;
  161.                         AFKOldPosZ[i]=0.0;
  162.                         TextDrawSetString(Textdraw6[i],"0");
  163.                         AFKTime[i]=MAX_AFKTIME;
  164.                     }
  165.                     else if(AFKTime[i] == 20)
  166.                     {
  167.                        
  168.  
  169.                         TextDrawSetString(Textdraw6[i],"20");
  170.                         TextDrawShowForPlayer(i,Textdraw0[i]);
  171.                         TextDrawShowForPlayer(i,Textdraw1[i]);
  172.                         TextDrawShowForPlayer(i,Textdraw2[i]);
  173.                         TextDrawShowForPlayer(i,Textdraw3[i]);
  174.                         TextDrawShowForPlayer(i,Textdraw4[i]);
  175.                         TextDrawShowForPlayer(i,Textdraw5[i]);
  176.                         TextDrawShowForPlayer(i,Textdraw6[i]);
  177.                     }
  178.                     else if(AFKTime[i] > 0 && AFKTime[i] < 20)
  179.                     {
  180.                        
  181.                         new string[32];
  182.                         format(string,sizeof(string),"%i", AFKTime[i]);
  183.                         TextDrawSetString(Textdraw6[i],string);
  184.                     }
  185.                 }
  186.                 else
  187.                 {
  188.                    
  189.                     TextDrawHideForPlayer(i,Textdraw0[i]);
  190.                     TextDrawHideForPlayer(i,Textdraw1[i]);
  191.                     TextDrawHideForPlayer(i,Textdraw2[i]);
  192.                     TextDrawHideForPlayer(i,Textdraw3[i]);
  193.                     TextDrawHideForPlayer(i,Textdraw4[i]);
  194.                     TextDrawHideForPlayer(i,Textdraw5[i]);
  195.                     TextDrawHideForPlayer(i,Textdraw6[i]);
  196.                     AFKTime[i]= MAX_AFKTIME;
  197.                     AFKOldPosX[i] = AFKNewPosX[i];
  198.                     AFKOldPosY[i] = AFKNewPosY[i];
  199.                     AFKOldPosZ[i] = AFKNewPosZ[i];
  200.                 }
  201.             }
  202.         }
  203.         else
  204.         {
  205.            
  206.             SetPlayerHealth(i,999999);
  207.         }
  208.     }
  209. }
  210.  
  211. public OnPlayerCommandText(playerid, commandid, params[]) {
  212.  
  213.     switch(commandid) {
  214.  
  215.         case iscmd("a,f,k"): {
  216.             if(AFK[playerid] == true)
  217.             {
  218.                
  219.                 AFK[playerid] = false;
  220.                 SetPlayerHealth(playerid,VidaAntes[playerid]);
  221.                 VidaAntes[playerid] = 0;
  222.                 TogglePlayerControllable(playerid,true);
  223.                 SendClientMessage(playerid,-1,"[Anti-AFK:] Já não estás AFK! Cuidado para não seres Kickado!");
  224.             }
  225.             else
  226.             {
  227.                
  228.                 AFK[playerid] = true;
  229.                 GetPlayerHealth(playerid,VidaAntes[playerid]);
  230.                 SendClientMessage(playerid,-1,"[Anti-AFK:] Estás agora AFK! Não serás Kickado por AFK!");
  231.                 SetPlayerHealth(playerid,999999);
  232.                 TogglePlayerControllable(playerid,false);
  233.             }
  234.             return true;
  235.         }
  236.  
  237.         default: return SendClientMessage(playerid, -1, "[Erro]: Comando errado!");
  238.     }
  239.  
  240.     return false;
  241. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement