Guest User

Untitled

a guest
Sep 13th, 2013
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. //===< _Maoriko_ AFK System >===//
  2.  
  3. //===< includes >===//
  4. #include <a_samp>
  5.  
  6. //===< defines >===//
  7. #define SendFormatMessage(%0,%1,%2,%3) format(String, sizeof(String),%2,%3) && SendClientMessage(%0, %1, String)
  8. #define SendFormatMessageToAll(%0,%1,%2) format(String, sizeof(String),%1,%2) && SendClientMessageToAll(%0, String)
  9.  
  10. //===< enums >===//
  11. enum AfkInfo
  12. {
  13. pName[MAX_PLAYER_NAME],
  14. bool:InAFK
  15. };
  16.  
  17. //===< news >===//
  18. new aInfo[MAX_PLAYERS][AfkInfo];
  19. new String[128];
  20.  
  21. public OnPlayerConnect(playerid) return GetPlayerName(playerid, aInfo[playerid][pName], MAX_PLAYER_NAME);
  22.  
  23. public OnPlayerCommandText(playerid, cmdtext[])
  24. {
  25. if(!strcmp(cmdtext, "/AFK", true))
  26. {
  27. if(aInfo[playerid][InAFK] == true)
  28. {
  29. aInfo[playerid][InAFK] = false;
  30. SendClientMessage(playerid, -1, "{FF0000}[AFK-System] {FFFFFF}You went AFK mode successfully");
  31. SendFormatMessageToAll(-1, "{FF0000}[AFK-System] {FFFFFF}The player %s successfully returned from AFK Mode", aInfo[playerid][pName]);
  32. TogglePlayerControllable(playerid, true);
  33. return true;
  34. }
  35. else
  36. {
  37. aInfo[playerid][InAFK] = true;
  38. SendClientMessage(playerid, -1, "{FF0000}[AFK-System] {FFFFFF}AFK successfully enters");
  39. SendFormatMessageToAll(-1, "{FF0000}[AFK-System] {FFFFFF}The player %s enters AFK Mode", aInfo[playerid][pName]);
  40. TogglePlayerControllable(playerid, false);
  41. }
  42. return true;
  43. }
  44. if(aInfo[playerid][InAFK] == true) return SendClientMessage(playerid, -1, "{FF0000}[AFK-System] {FFFFFF}You can't type commands when you in AFK Mode");
  45.  
  46. if(!strcmp(cmdtext, "/AFKList", true))
  47. {
  48. new AFKCount;
  49. for(new i; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && aInfo[i][InAFK] == true)
  50. {
  51. AFKCount++;
  52. SendClientMessage(playerid, -1, "{FF0000}[AFK-System] {FFFFFF}Players in AFK Mode List");
  53. SendFormatMessage(playerid, -1, "{FF0000}[AFK-System] {FFFFFF}>> {FF0000}%s {FFFFFF}[ID: %d]", aInfo[i][pName], i);
  54. }
  55. if(AFKCount == 0) return SendClientMessage(playerid, -1, "{FF0000}[AFK-System] {FFFFFF}There is no players in AFK Mode");
  56. }
  57. return false;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment