Advertisement
Guest User

Untitled

a guest
May 7th, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.52 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define COLOR_WHITE 0xFFFFFF
  4. new AFK[MAX_PLAYERS];
  5. new string[64];
  6. new afkSeconds[MAX_PLAYERS];
  7. new afkMinutes[MAX_PLAYERS];
  8. new afkHours[MAX_PLAYERS];
  9.  
  10.  
  11.  
  12. public OnPlayerConnect(playerid)
  13. {
  14.     AFK[playerid] = 0;
  15.     return 1;
  16. }
  17.  
  18. public OnPlayerDisconnect(playerid, reason)
  19. {
  20.     AFK[playerid] = 0;
  21.     return 1;
  22. }
  23.  
  24. public OnPlayerText(playerid, text[])
  25. {
  26.         if(AFK[playerid])
  27.         return SendClientMessage(playerid, COLOR_WHITE, "Your AFK , You Cant Talk, to back type : /unafk"),0;
  28.         return 1;
  29. }
  30.  
  31. public OnPlayerCommandText(playerid, cmdtext[])
  32. {
  33.     if(AFK[playerid])
  34.     return SendClientMessage(playerid, COLOR_WHITE, "Your AFK, You Cant Use Commands , for back Type : /unafk"),0;
  35.     if (strcmp("/afk", cmdtext, true, 10) == 0)
  36.     {
  37.         new afkTimers[MAX_PLAYERS];
  38.         afkTimers[playerid] = SetTimerEx("afkTimers", 1000, true, "i", playerid);
  39.         AFK[playerid] = 1;
  40.         SendClientMessage(playerid,COLOR_WHITE,"Your Now AFK, To Back Press : /unafk");
  41.         format(string,sizeof(string),"%s Is Now AFK !",GetName(playerid));
  42.         SendClientMessageToAll(COLOR_WHITE, string);
  43.         TogglePlayerControllable(playerid, 0);
  44.         ResetPlayerWeapons(playerid);
  45.         return 1;
  46.     }
  47.    
  48.     if (strcmp("/unafk", cmdtext, true, 10) == 0)
  49.     {
  50.         new afkTimers[MAX_PLAYERS];
  51.         KillTimer(afkTimers[playerid]);
  52.         AFK[playerid] = 0;
  53.         SendClientMessage(playerid, COLOR_WHITE, "Your Back From AFK, Have Fun");
  54.         format(string,sizeof(string),"%s Back From AFK !",GetName(playerid));
  55.         SendClientMessageToAll(COLOR_WHITE, string);
  56.         TogglePlayerControllable(playerid, 1);
  57.         ResetPlayerWeapons(playerid);
  58.     }
  59.     return 0;
  60. }
  61.  
  62. stock GetName(playerid)
  63. {
  64.     new szName[MAX_PLAYER_NAME];
  65.     GetPlayerName(playerid, szName, sizeof(szName));
  66.     return szName;
  67. }
  68.  
  69. forward afkTimers(playerid);
  70. public afkTimers(playerid)
  71. {
  72.         new Float:X,Float:Y,Float:Z;
  73.         format(string,sizeof(string),"%d");
  74.         AFK[playerid] = Create3DTextLabel(string, 0xff22ff, X,Y,Z, 40.0, 0, 0);
  75.         for(new i=0; i < MAX_PLAYERS; i++)
  76.         {
  77.                 if(IsPlayerConnected(i) && AFK[i])
  78.                 {
  79.                         afkSeconds[i]++;
  80.                         if(afkSeconds[i] >= 60)
  81.                         {
  82.                                 afkMinutes[i]++;
  83.                                 if(afkMinutes[i] >= 60)
  84.                                 {
  85.                                         afkHours[i]++;
  86.                                 }
  87.                         }
  88.                 }
  89.         }
  90.         return 1;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement