MonkSRB

m_AFK System by Monk

Mar 17th, 2012
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.55 KB | None | 0 0
  1. #include <a_samp>
  2. #include <foreach>
  3. #include <sscanf2>
  4. #include <YSI\y_commands>
  5.  
  6. #define COLOR_WHITE 0xFFFFFFFF
  7.  
  8. #define WHITE   "{FFFFFF}"
  9. #define LBLUE   "{347CCF}"
  10.  
  11. forward AFK_Seconds(playerid);
  12.  
  13. new Text3D:AFK_Label[MAX_PLAYERS];
  14. new IsPlayerAFK[MAX_PLAYERS];
  15. new AFK_Timer[MAX_PLAYERS];
  16. new AFK_Reason[MAX_PLAYERS];
  17.  
  18. main()
  19. {
  20.     print("\n----------------------------------");
  21.     print("      m_AFK System v1.1 by Monk     ");
  22.     print("----------------------------------\n");
  23. }
  24.  
  25. public OnPlayerConnect(playerid)
  26. {
  27.     IsPlayerAFK[playerid] = 0;
  28.     SendClientMessage(playerid, COLOR_WHITE, "This srever has m_AFK system v1.1 by Monk. (/afk & /back)");
  29.     return 1;
  30. }
  31.  
  32. YCMD:afk(playerid, params[], help)
  33. {
  34.     new reason[64], strtext[64];
  35.     if(IsPlayerAFK[playerid] == 1) return SendClientMessage(playerid, COLOR_WHITE, "You are alredy AFK.");
  36.     if(sscanf(params,"s[64]", reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /afk [reason]");
  37.     IsPlayerAFK[playerid] = 1;
  38.     TogglePlayerControllable(playerid, false);
  39.     new string[64], plname[MAX_PLAYER_NAME];
  40.     GetPlayerName(playerid, plname, MAX_PLAYER_NAME);
  41.     format(string, sizeof(string), ""WHITE"%s "LBLUE"is now AFK", plname);
  42.     SendClientMessageToAll(COLOR_WHITE, string);
  43.     format(AFK_Reason[playerid],64,"%s", reason);
  44.     format(strtext, sizeof(strtext), ""LBLUE"Player is AFK\n"WHITE"Reason: %s\nTime: 0", reason);
  45.     AFK_Label[playerid] = Create3DTextLabel(strtext,COLOR_WHITE,30.0,40.0,50.0,40.0,0);
  46.     Attach3DTextLabelToPlayer(AFK_Label[playerid], playerid, 0.0, 0.0, 0.3);
  47.     SendClientMessage(playerid, COLOR_WHITE, "You are now AFK,tyre "LBLUE"/back "WHITE"when you come back.");
  48.     SetTimer("AFK_Seconds", 1000, true);
  49.     return 1;
  50. }
  51. YCMD:back(playerid, params[], help)
  52. {
  53.     if(IsPlayerAFK[playerid] == 0) return SendClientMessage(playerid, COLOR_WHITE, "You are not AFK.");
  54.     IsPlayerAFK[playerid] = 0;
  55.     TogglePlayerControllable(playerid, true);
  56.     new string[64], plname[MAX_PLAYER_NAME];
  57.     GetPlayerName(playerid, plname, MAX_PLAYER_NAME);
  58.     format(string, sizeof(string), ""WHITE"%s "LBLUE"is no longer AFK", plname);
  59.     SendClientMessageToAll(COLOR_WHITE, string);
  60.     Delete3DTextLabel(Text3D:AFK_Label[playerid]);
  61.     SendClientMessage(playerid, COLOR_WHITE, "You are no longer AFK.");
  62.     return 1;
  63. }
  64.  
  65. public AFK_Seconds(playerid)
  66. {
  67.     foreach (Player, i)
  68.     {
  69.         AFK_Timer[i] += 1;
  70.         new string[64];
  71.         format(string, sizeof(string), ""LBLUE"Player is AFK\n"WHITE"Reason: %s\nTime: %d", AFK_Reason[playerid], AFK_Timer[i]);
  72.         Update3DTextLabelText(AFK_Label[i], COLOR_WHITE, string);
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment