Advertisement
Private200

AFK System

Mar 27th, 2013
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. // Some news for the name changes
  4.  
  5. new names[24], string[128];
  6. new PlayerText3D:afktext;
  7. new IsAfk[MAX_PLAYERS];
  8.  
  9. // End of the news.
  10.  
  11. public OnFilterScriptInit()
  12. {
  13. print("\n--------------------------------------");
  14. print(" Script created by Private200");
  15. print("--------------------------------------\n");
  16. return 1;
  17. }
  18.  
  19. public OnPlayerCommandText(playerid, cmdtext[])
  20. {
  21.  
  22. new Float:X, Float:Y, Float:Z;
  23.  
  24. GetPlayerName(playerid, names, sizeof(names));
  25.  
  26. if (strcmp("/afk", cmdtext, true, 10) == 0)
  27. {
  28. if(IsAfk[playerid]) return SendClientMessage(playerid, 0xADD8E6FF, "You're already in AFK mode.");
  29. IsAfk[playerid] = 1;
  30. TogglePlayerControllable(playerid, 0);
  31. format(string,sizeof(string),"%s {FFFFFF} is now in AFK mode.", names);
  32. SendClientMessageToAll(0xADD8E6FF, string);
  33. GetPlayerPos(playerid, X, Y, Z);
  34. afktext = CreatePlayer3DTextLabel(playerid,"{FF0000}Player is in AFK mode.",0x008080FF, X,Y,Z,40.0);
  35. return 1;
  36. }
  37. if (strcmp("/back", cmdtext, true, 10) == 0)
  38. {
  39. if(IsAfk[playerid] == 1)
  40. {
  41. Afk_Back(playerid);
  42. }
  43. else
  44. SendClientMessage(playerid, 0xADD8E6FF, "You're not in AFK mode.");
  45. return 1;
  46. }
  47. return 0;
  48. }
  49.  
  50. /*public OnPlayerStateChange(playerid, newstate, oldstate)
  51. {
  52. if(IsAfk[playerid] == 1)
  53. {
  54. Afk_Back(playerid);
  55. }
  56. else
  57. SendClientMessage(playerid, 0xADD8E6FF, "You're not in AFK mode.");
  58. return 1;
  59. }*/
  60.  
  61. public OnPlayerText(playerid,text[])
  62. {
  63. if(IsAfk[playerid] == 1)
  64. {
  65. Afk_Back(playerid);
  66. }
  67. else
  68. SendClientMessage(playerid, 0xADD8E6FF, "You're not in AFK mode.");
  69. return 1;
  70. }
  71.  
  72. stock Afk_Back(playerid)
  73. {
  74. IsAfk[playerid] = 0;
  75. TogglePlayerControllable(playerid, 1);
  76. format(string,sizeof(string),"%s {FFFFFF} is now BACK from AFK mode.", names);
  77. SendClientMessageToAll(0xADD8E6FF, string);
  78. DeletePlayer3DTextLabel(playerid, afktext);
  79. return 1;
  80. }
  81.  
  82.  
  83. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  84. {
  85. new OtherPlayerName[24], OtherPlayer;
  86.  
  87. GetPlayerName(OtherPlayer, OtherPlayerName, sizeof(OtherPlayerName));
  88.  
  89. if(IsAfk[clickedplayerid] == 1)
  90. {
  91. format(string, 128, "%s {FFFFFF}is in AFK mode.", OtherPlayerName);
  92. SendClientMessage(playerid, 0xADD8E6FF, string);
  93. }
  94. else
  95. format(string, 128, "%s {FFFFFF}is not in AFK mode.", OtherPlayerName);
  96. SendClientMessage(playerid, 0xADD8E6FF, string);
  97. return 1;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement