Advertisement
Johurt

[SCR] AFK system.

Dec 10th, 2012
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.12 KB | None | 0 0
  1. /*
  2.     AFK system by Johurt(ES.^).
  3. */
  4. #include <a_samp>
  5.  
  6. new bool:AFK_Stat[MAX_PLAYERS], Text3D:AFK_Label[MAX_PLAYERS];
  7.  
  8. public OnPlayerConnect(playerid)
  9. {
  10.     AFK_Stat[playerid] = false;
  11.     AFK_Label[playerid] = Text3D:INVALID_3DTEXT_ID;
  12.     return 1;
  13. }
  14.  
  15. public OnPlayerDisconnect(playerid, reason)
  16. {
  17.     if(AFK_Label[playerid] != Text3D:INVALID_3DTEXT_ID) Delete3DTextLabel(AFK_Label[playerid]);
  18.     return 1;
  19. }
  20.  
  21. public OnGameModeInit()
  22. {
  23.     SetTimer("OneSecond", 1000, true);
  24.     return 1;
  25. }
  26.  
  27. public OnPlayerUpdate(playerid)
  28. {
  29.     if(AFK_Label[playerid] != Text3D:INVALID_3DTEXT_ID)
  30.     {
  31.         Delete3DTextLabel(AFK_Label[playerid]);
  32.         AFK_Label[playerid] = Text3D:INVALID_3DTEXT_ID;
  33.     }
  34.     AFK_Stat[playerid] = false;
  35.     return 1;
  36. }
  37.  
  38. forward OneSecond();
  39. public OneSecond()
  40. {
  41.     for(new p = 0; p < MAX_PLAYERS; p++)
  42.     {
  43.         if(IsPlayerNPC(p) || !IsPlayerConnected(p)) continue;
  44.         if(AFK_Stat[p] && AFK_Label[p] == Text3D:INVALID_3DTEXT_ID)
  45.         {
  46.             AFK_Label[p] = Create3DTextLabel("AFK", 0xFFFFFFFF, 0.0, 0.0, 0.0, 15.0, 0, 1);
  47.             Attach3DTextLabelToPlayer(AFK_Label[p], p, 0.0, 0.0, 0.5);
  48.         }
  49.         AFK_Stat[p] = true;
  50.     }
  51.     return 1;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement