Advertisement
Guest User

Afk System by Audi_Quattrix

a guest
Jul 30th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. // Simple afk system by Audi_Quattrix
  2. #define FILTERSCRIPT
  3.  
  4. #include <a_samp>
  5. #include <zcmd>
  6.  
  7. #if defined FILTERSCRIPT
  8. #define DRED 0xFF0000AA
  9. #define WHITE 0xFFFFFFFF
  10. new AFK[MAX_PLAYERS];
  11. new BRB[MAX_PLAYERS];
  12.  
  13. public OnFilterScriptInit()
  14. {
  15. print("\n--------------------------------------");
  16. print(" AFK system by Audi_Quattrix loaded");
  17. print("--------------------------------------\n");
  18. return 1;
  19. }
  20.  
  21. public OnFilterScriptExit()
  22. {
  23. print("\n--------------------------------------");
  24. print(" AFK system by Audi_Quattrix unloaded");
  25. print("--------------------------------------\n");
  26. return 1;
  27. }
  28. public OnPlayerConnect(playerid)
  29. {
  30. AFK[playerid] = 0;
  31. BRB[playerid] = 0;
  32. return 1;
  33. }
  34. CMD:afk(playerid)
  35. {
  36. if (AFK[playerid] == 1)
  37. {
  38. SendClientMessage(playerid,DRED,"You are already AFK!");
  39. }
  40. else
  41. {
  42. new string[128];
  43. format(string,sizeof(string)," %s is now Away From Keyboard (AFK)",GetPlayerNameEx(playerid));
  44. SendClientMessageToAll(WHITE,string);
  45. TogglePlayerControllable(playerid,0);
  46. SendClientMessage(playerid,WHITE,"You are now AFK!");
  47. AFK[playerid] = 1;
  48. }
  49. return 1;
  50. }
  51. CMD:brb(playerid)
  52. {
  53. if (BRB[playerid] == 1)
  54. {
  55. SendClientMessage(playerid,DRED,"You are already AFK!");
  56. }
  57. else
  58. {
  59. new string[128];
  60. format(string,sizeof(string)," %s will be right back (BRB)",GetPlayerNameEx(playerid));
  61. SendClientMessageToAll(WHITE,string);
  62. TogglePlayerControllable(playerid,0);
  63. SendClientMessage(playerid,WHITE,"You are now AFK!");
  64. BRB[playerid] = 1;
  65. }
  66. return 1;
  67. }
  68. CMD:back(playerid)
  69. {
  70. if (AFK[playerid] == 0 && BRB[playerid] == 0)
  71. {
  72. SendClientMessage(playerid,DRED,"You are already back!");
  73. }
  74. else
  75. {
  76. new string[128];
  77. format(string,sizeof(string)," %s is now back!",GetPlayerNameEx(playerid));
  78. SendClientMessageToAll(WHITE,string);
  79. TogglePlayerControllable(playerid,1);
  80. SendClientMessage(playerid,WHITE,"Welcome back!");
  81. AFK[playerid] = 0;
  82. BRB[playerid] = 0;
  83. }
  84. return 1;
  85. }
  86. CMD:afklist(playerid)
  87. {
  88. SendClientMessage(playerid,WHITE,"AFK players:");
  89. for(new i = 0; i < MAX_PLAYERS; i++)
  90. {
  91. if(IsPlayerConnected(i))
  92. {
  93. if(AFK[i] == 1 || BRB[i] == 1)
  94. {
  95. new name[MAX_PLAYER_NAME];
  96. new string[128];
  97. GetPlayerName(i,name,sizeof(name));
  98. format(string,sizeof(string),"Name: %s || Player ID: %i",name,i);
  99. SendClientMessage(playerid,WHITE,string);
  100. }
  101. }
  102. }
  103. return 1;
  104. }
  105. stock GetPlayerNameEx(playerid)
  106. {
  107. new Name[MAX_PLAYER_NAME];
  108. GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
  109. return Name;
  110. }
  111. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement