khalifakk

[SAMP] Afk/Brb System

Jul 15th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.15 KB | None | 0 0
  1. // Afk/Brb System
  2. // khalifakk 2014
  3.  
  4. #include <a_samp>
  5.  
  6. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  7.  
  8. #pragma tabsize 0
  9.  
  10.  
  11. //Colors
  12. #define COLOR_WHITE 0xFFFFFFAA
  13. #define COLOR_GREEN 0x00FF00AA
  14. #define COLOR_RED 0xFF0000AA
  15. #define COLOR_LIGHTBLUE 0x33CCFFAA
  16. #define COLOR_YELLOW 0xFFFF00AA
  17. enum Player
  18. {
  19.     AFKstatus
  20. }
  21. new PlayerInfo[MAX_PLAYERS][Player];
  22. public OnFilterScriptInit()
  23. {
  24.         print("\n--------------------------------------");
  25.         print(" AFK/BRB System Successfully Loaded!    ");
  26.         print("--------------------------------------\n");
  27.         return 1;
  28. }
  29.  
  30. public OnFilterScriptExit()
  31. {
  32.         return 1;
  33. }
  34.  
  35. dcmd_afk(playerid, params[])
  36.         {
  37.             #pragma unused params
  38.                 new string[256];
  39.                 if (PlayerInfo[playerid][AFKstatus] == 1)
  40.                 {
  41.                         SendClientMessage(playerid, COLOR_RED, "ERROR: Your status is already AFK/BRB!");
  42.                         return 1;
  43.                 }
  44.  
  45.                 else if (PlayerInfo[playerid][AFKstatus] == 0)
  46.                 {
  47.                         new pname[MAX_PLAYER_NAME];
  48.                         GetPlayerName(playerid, pname, sizeof(pname));
  49.                         format(string, sizeof(string), "%s (ID:%d) is away from keyboard!", pname,playerid);
  50.                         SendClientMessageToAll(COLOR_YELLOW, string);
  51.                         TogglePlayerControllable(playerid,0);
  52.                         SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) + 50);
  53.                         PlayerInfo[playerid][AFKstatus] = 1;
  54.                         return 1;
  55.                 }
  56. return 0;
  57. }
  58.  
  59. dcmd_brb(playerid, params[])
  60.         {
  61.             #pragma unused params
  62.                 new string[256];
  63.                 if (PlayerInfo[playerid][AFKstatus] == 1)
  64.                 {
  65.                         SendClientMessage(playerid, COLOR_RED, "ERROR: You are Already AFK/And or BRB");
  66.                         return 1;
  67.                 }
  68.  
  69.                 else if (PlayerInfo[playerid][AFKstatus] == 0)
  70.                 {
  71.                         new pname[MAX_PLAYER_NAME];
  72.                         GetPlayerName(playerid, pname, sizeof(pname));
  73.                         format(string, sizeof(string), "%s (ID:%d) Will Be Right Back (BRB)", pname,playerid);
  74.                         SendClientMessageToAll(COLOR_GREEN, string);
  75.                         TogglePlayerControllable(playerid,0);
  76.                         SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) + 50);
  77.                         PlayerInfo[playerid][AFKstatus] = 1;
  78.                         return 1;
  79.  }
  80. return 0;
  81. }
  82.  
  83. dcmd_back(playerid, params[])
  84.         {
  85.                 #pragma unused params
  86.                 new string [256];
  87.                 if (PlayerInfo[playerid][AFKstatus] == 0)
  88.                 {
  89.                         SendClientMessage(playerid, COLOR_RED, "ERROR: You are Already Back!");
  90.                         return 1;
  91.                 }
  92.  
  93.                 else if (PlayerInfo[playerid][AFKstatus] == 1)
  94.                 {
  95.                         new pname[MAX_PLAYER_NAME];
  96.                         GetPlayerName(playerid, pname, sizeof(pname));
  97.                         format(string, sizeof(string), "%s (ID:%d) has Came Back!!!", pname,playerid);
  98.                         SendClientMessageToAll(COLOR_GREEN, string);
  99.                         TogglePlayerControllable(playerid,1);
  100.                         SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) - 50);
  101.                         PlayerInfo[playerid][AFKstatus] = 0;
  102.                         return 1;
  103.  }
  104. return 0;
  105. }
  106.  
  107.  
  108. dcmd_afkplayers( playerid, params[ ] )
  109. {
  110.     #pragma unused params
  111.         new count = 0;
  112.         new name[MAX_PLAYER_NAME];
  113.                 new string[128];
  114.         //
  115.                 SendClientMessage(playerid, COLOR_WHITE, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
  116.                 SendClientMessage(playerid, COLOR_LIGHTBLUE, "The Afk List:");
  117.                 SendClientMessage(playerid, COLOR_WHITE, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
  118.         for(new i = 0; i < MAX_PLAYERS; i++)
  119.                 {
  120.                         if (IsPlayerConnected(i))
  121.                         {
  122.  
  123.                             if(PlayerInfo[i][AFKstatus] == 1)
  124.                             {
  125.                                         GetPlayerName(i, name, sizeof(name));
  126.                                         format(string, 256, "AFK> %s{FFFFFF} (ID:%d)", name,i );
  127.                                         SendClientMessage(playerid, COLOR_YELLOW, string);
  128.                                 count++;
  129.                                 }
  130.                         }
  131.  
  132.                 }
  133.                 if (count == 0)
  134.                 {
  135.                 SendClientMessage(playerid, COLOR_RED, "No players are Afk or Brb");
  136.                 }
  137.                 SendClientMessage(playerid, COLOR_WHITE, "-=---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
  138.                 return 1;
  139. }
  140.  
  141. public OnPlayerConnect(playerid)
  142. {
  143.     PlayerInfo[playerid][AFKstatus] = 0;
  144.     new string[256];
  145.     new pname[MAX_PLAYER_NAME];
  146.     format(string, sizeof(string), "In case you want to go away or pause the game use: {f0ff00}/afk or /brb and if you want to play again use: {f0ff00}/back");
  147.     SendClientMessageToAll(COLOR_GREEN, string);
  148.     return 1;
  149. }
  150.  
  151. public OnPlayerDisconnect(playerid, reason)
  152. {
  153.         PlayerInfo[playerid][AFKstatus] = 0;
  154.         return 1;
  155. }
  156.  
  157.  
  158.  
  159. public OnPlayerText(playerid, text[])
  160. {
  161.         if (PlayerInfo[playerid][AFKstatus] == 1)
  162.         {
  163.                 SendClientMessage(playerid, COLOR_RED, "Dude, Use /back To Speak Again Please!!");
  164.                 return 0;
  165.         }
  166.  
  167.         else if (PlayerInfo[playerid][AFKstatus] == 0)
  168.         {
  169.                 return 1;
  170.         }
  171.         return 1;
  172. }
  173.  
  174. public OnPlayerCommandText(playerid, cmdtext[])
  175. {
  176.         dcmd(afk,3,cmdtext);
  177.         dcmd(brb,3,cmdtext);
  178.         dcmd(back,4,cmdtext);
  179.         dcmd(afkplayers,10,cmdtext);
  180.         return 0;
  181. }
Advertisement
Add Comment
Please, Sign In to add comment