Advertisement
Guest User

ST4NL3Y

a guest
Dec 23rd, 2009
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.59 KB | None | 0 0
  1. #include <a_samp>
  2. #define MAX_AFK_TIMER 60000*2
  3. new upd[MAX_PLAYERS]=0;
  4. new afking[MAX_PLAYERS]=0;
  5. new sended[MAX_PLAYERS]=0;
  6. new debafk[MAX_PLAYERS]=0;
  7. new originame[MAX_PLAYERS][24];
  8.  
  9.  
  10. public OnFilterScriptInit()
  11. {
  12.     print("\n--------------------------------------");
  13.     print("Extreme AFK checker By ST4]N[L3Y");
  14.     print("--------------------------------------\n");
  15.     SetTimer("update",3900,1);
  16.     return 1;
  17. }
  18.  
  19. public OnFilterScriptExit()
  20. {
  21.     return 1;
  22. }
  23.  
  24.  
  25. public OnPlayerText(playerid,text[])
  26. {
  27.     if(afking[playerid]==1&&upd[playerid]!=0 && sended[playerid]==1)
  28.     {
  29.         SetPlayerName(playerid,originame[playerid]);
  30.         sended[playerid]=0;
  31.         afking[playerid]=0;
  32.     }
  33.     return 1;
  34. }
  35.  
  36. public OnPlayerConnect(playerid)
  37. {
  38.     debafk[playerid]=0;
  39.     format(originame[playerid],24,"%s",PlayerName(playerid));
  40.     return 1;
  41. }
  42.  
  43. public OnPlayerDisconnect(playerid, reason)
  44. {
  45.     SetPlayerName(playerid,originame[playerid]);
  46.     debafk[playerid]=0;
  47.     return 1;
  48. }
  49.  
  50. public OnPlayerSpawn(playerid)
  51. {
  52.     debafk[playerid]=1;
  53.     return 1;
  54. }
  55.  
  56.  
  57. public OnPlayerStateChange(playerid, newstate, oldstate)
  58. {
  59.     if(afking[playerid]==1&&upd[playerid]!=0 && sended[playerid]==1)
  60.     {
  61.         SetPlayerName(playerid,originame[playerid]);
  62.         sended[playerid]=0;
  63.         afking[playerid]=0;
  64.     }
  65.     return 1;
  66. }
  67.  
  68.  
  69. forward OnPlayerUpdate(playerid);
  70. public OnPlayerUpdate(playerid)
  71. {
  72.     upd[playerid]++;
  73.     return 1; // <----------- thx to peppe <3
  74. }
  75.  
  76.  
  77.  
  78. new timmaxafk[MAX_PLAYERS];
  79.  
  80. forward update();
  81. public update()
  82. {
  83.     for (new i=0;i<MAX_PLAYERS;i++)
  84.     {
  85.     if(IsPlayerConnected(i))
  86.         {
  87.             if(upd[i]==0 && sended[i]==0 && debafk[i]==1)
  88.             {
  89.                 if(strlen(PlayerName(i))<=MAX_PLAYER_NAME-6)
  90.                 {
  91.                     new name[MAX_PLAYER_NAME];
  92.                     format(name,MAX_PLAYER_NAME,"[AFK]%s",PlayerName(i));
  93.                     SetPlayerName(i,name);
  94.                     KillTimer(timmaxafk[i]);
  95.                     timmaxafk[i]=SetTimerEx("maxafk",MAX_AFK_TIMER,0,"i",i);
  96.                     sended[i]=1;
  97.                     afking[i]=1;
  98.                 }else{
  99.                     new string[190];
  100.                     format(string,190,"%s is now away from key board",PlayerName(i));
  101.                     SendClientMessageToAll(0x00ff00aa,string);
  102.                     KillTimer(timmaxafk[i]);
  103.                     timmaxafk[i]=SetTimerEx("maxafk",MAX_AFK_TIMER,0,"i",i);
  104.                     sended[i]=1;
  105.                     afking[i]=1;
  106.                 }
  107.                
  108.                 }else if(afking[i]==1&&upd[i]!=0 && sended[i]==1)
  109.                 {
  110.                     SetPlayerName(i,originame[i]);
  111.                     sended[i]=0;
  112.                     afking[i]=0;
  113.                 }
  114.             upd[i]=0;
  115.         }
  116.     }
  117. }
  118.  
  119.  
  120. forward maxafk(i);
  121. public maxafk(i)
  122. {
  123.     Kick(i);
  124. }
  125.  
  126. stock PlayerName(playerid)
  127. {
  128.     new name[25];
  129.     GetPlayerName(playerid, name, 25);
  130.     return name;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement