Advertisement
Guest User

Untitled

a guest
May 7th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.56 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]) return SendClientMessage(playerid, COLOR_WHITE, "Your AFK, You Cant Use Commands , for back Type : /unafk"),0;
  34.     if (strcmp("/afk", cmdtext, true, 10) == 0)
  35.     {
  36.         new afkTimers[MAX_PLAYERS];
  37.         afkTimers[playerid] = SetTimerEx("afkTimers", 1000, true, "i", playerid);
  38.         AFK[playerid] = 1;
  39.         SendClientMessage(playerid,COLOR_WHITE,"Your Now AFK, To Back Press : /unafk");
  40.         format(string,sizeof(string),"%s Is Now AFK !",GetName(playerid));
  41.         SendClientMessageToAll(COLOR_WHITE, string);
  42.         TogglePlayerControllable(playerid, 0);
  43.         ResetPlayerWeapons(playerid);
  44.         return 1;
  45.     }
  46.  
  47.     if(AFK[playerid] && strcmp(cmdtext,"/unafk",true))
  48.     {
  49.         new afkTimers[MAX_PLAYERS];
  50.         KillTimer(afkTimers[playerid]);
  51.         AFK[playerid] = 0;
  52.         SendClientMessage(playerid, COLOR_WHITE, "Your Back From AFK, Have Fun");
  53.         format(string,sizeof(string),"%s Back From AFK !",GetName(playerid));
  54.         SendClientMessageToAll(COLOR_WHITE, string);
  55.         TogglePlayerControllable(playerid, 1);
  56.         ResetPlayerWeapons(playerid);
  57.     }
  58.     return 0;
  59. }
  60.  
  61. stock GetName(playerid)
  62. {
  63.     new szName[MAX_PLAYER_NAME];
  64.     GetPlayerName(playerid, szName, sizeof(szName));
  65.     return szName;
  66. }
  67.  
  68. forward afkTimers(playerid);
  69. public afkTimers(playerid)
  70. {
  71.         new Float:X,Float:Y,Float:Z;
  72.         GetPlayerPos(playerid, X, Y, 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