Guest User

Joe Torran C

a guest
May 5th, 2010
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. // Torran's AFK System
  2. // Made by Torran
  3. // DO NOT REMOVE THESE CREDITS
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7.  
  8. #define COLOR_YELLOW 0xFFFF00FF
  9. #define COLOR_RED 0xFF0000FF
  10.  
  11. forward afk_OnPlayerConnect(playerid);
  12. forward afk_OnPlayerDisconnect(playerid);
  13. forward afk_OnPlayerText(playerid, text[]);
  14.  
  15. new playerAFK[MAX_PLAYERS];
  16. new Text3D:AFKLabel[MAX_PLAYERS];
  17.  
  18. public afk_OnPlayerConnect(playerid)
  19. {
  20. playerAFK[playerid] = 0;
  21. return 1;
  22. }
  23.  
  24. public afk_OnPlayerDisconnect(playerid)
  25. {
  26. Delete3DTextLabel(AFKLabel[playerid]);
  27. return 1;
  28. }
  29.  
  30. public afk_OnPlayerText(playerid, text[])
  31. {
  32. if(playerAFK[playerid] == 1)
  33. {
  34. SendClientMessage(playerid, COLOR_RED, "You cannot speak while AFK, To talk again please type /back");
  35. return 0;
  36. }
  37. return 1;
  38. }
  39.  
  40. CMD:afk(playerid, params[])
  41. {
  42. new string[128], name[MAX_PLAYER_NAME];
  43.  
  44. if(playerAFK[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You are already AFK");
  45.  
  46. GetPlayerName(playerid, name, sizeof name);
  47.  
  48. playerAFK[playerid] = 1;
  49. TogglePlayerControllable(playerid, 0);
  50.  
  51. SendClientMessage(playerid, COLOR_YELLOW, "You are now AFK, When back please type /back");
  52. format(string, sizeof string, "%s is now AFK", name);
  53. SendClientMessageToAll(COLOR_YELLOW, string);
  54.  
  55. AFKLabel[playerid] = Create3DTextLabel("I am AFK", COLOR_RED, 30.0, 40.0, 50.0, 40.0, 0);
  56. Attach3DTextLabelToPlayer(AFKLabel[playerid], playerid, 0.0, 0.0, 0.7);
  57. return 1;
  58. }
  59.  
  60. CMD:back(playerid, params[])
  61. {
  62. new string[128], name[MAX_PLAYER_NAME];
  63.  
  64. if(playerAFK[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You arent AFK");
  65.  
  66. GetPlayerName(playerid, name, sizeof name);
  67.  
  68. playerAFK[playerid] = 0;
  69. TogglePlayerControllable(playerid, 1);
  70.  
  71. SendClientMessage(playerid, COLOR_YELLOW, "You are now back");
  72. format(string, sizeof string, "%s is now back", name);
  73. SendClientMessageToAll(COLOR_YELLOW, string);
  74.  
  75. Delete3DTextLabel(AFKLabel[playerid]);
  76. return 1;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment