Advertisement
Guest User

AFK System by [KMA]Markx

a guest
Mar 4th, 2011
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.07 KB | None | 0 0
  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  2. /*++++++++++++++++++Made++++++++++++++++++++++++++++++++++++++++++++++*/
  3. /*++++++++++++++++++++++++by:+++++++++++++++++++++++++++++++++++++++++*/
  4. /*++++++++++++++++++++++++++++[KMA]Markx++++++++++++++++++++++++++++++*/
  5. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  6.  
  7. /*Includes*/
  8. #include <a_samp>
  9. #include <zcmd>
  10. /*Colors*/
  11. #define COLOR_YELLOW 0xFFFF00FF
  12. #define COLOR_RED 0xFF0000FF
  13. /*New's*/
  14. new IsPlayerAfk[MAX_PLAYERS];
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     print("\n--------------------------------------");
  19.     print("AFK System Made by [KMA]Markx lunched!");
  20.     print("--------------------------------------\n");
  21.     return 1;
  22. }
  23.  
  24. public OnFilterScriptExit()
  25. {
  26.     print("\n--------------------------------------");
  27.     print("AFK System Made by [KMA]Markx exited!");
  28.     print("--------------------------------------\n");
  29.     return 1;
  30. }
  31.  
  32.  
  33. public OnPlayerConnect(playerid)
  34. {
  35.     IsPlayerAfk[playerid] = 0;
  36.     SendClientMessage(playerid, COLOR_YELLOW, "This Server is using AFK system made by: [KMA]Markx"); //Delete this if you want
  37.     return 1;
  38. }
  39.  
  40. public OnPlayerDisconnect(playerid, reason)
  41. {
  42.     IsPlayerAfk[playerid] = 0;
  43.     return 1;
  44. }
  45.  
  46. public OnPlayerText(playerid, text[])
  47. {
  48.     if(IsPlayerAfk[playerid] == 1)
  49.     {
  50.     SendClientMessage(playerid, COLOR_RED, "ERROR : You can not use chat when you're AFK. Use /back to be back!");
  51.     return 0;
  52.     }
  53.     return 1;
  54. }
  55. /*-------------AFK Command-------------*/
  56. COMMAND:afk(playerid, params[])
  57. {
  58.     new name[256];
  59.     new afk[256];
  60.     #pragma unused params
  61.     if (IsPlayerAfk[playerid] == 0) {
  62.     new string[64], pName[MAX_PLAYER_NAME];
  63.     GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  64.     format(string,sizeof string,".::%s is now Away From Keyboard(AFK)::.",pName);
  65.     SendClientMessageToAll(COLOR_YELLOW,string);
  66.     GetPlayerName(playerid,name, sizeof(name));
  67.     format(afk, sizeof(afk), "~r~ ~n~  ~n~  ~n~  ~n~  ~n~  ~n~ ~n~ ~n~  ~n~ ~n~ ~r~ %s ~w~ is now AFK!", name);
  68.     GameTextForAll(afk,4000,3);
  69.     IsPlayerAfk[playerid] = 1;
  70.     return true;
  71.     }
  72.     if (IsPlayerAfk[playerid] == 1) {
  73.     SendClientMessage(playerid, COLOR_RED, "ERROR : You are alredy AFK! Use /back to be back!"); //Anti Spam
  74.     }
  75.     return true;
  76. }
  77. /*-------Back Command-------*/
  78. COMMAND:back(playerid, params[])
  79. {
  80.     new name[256];
  81.     new back[256];
  82.     #pragma unused params
  83.     if (IsPlayerAfk[playerid] == 1) {
  84.     new string[64], pName[MAX_PLAYER_NAME];
  85.     GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  86.     format(string,sizeof string,".::%s is now Back!::.",pName);
  87.     SendClientMessageToAll(COLOR_YELLOW,string);
  88.     GetPlayerName(playerid,name, sizeof(name));
  89.     format(back, sizeof(back), "~r~ ~n~  ~n~  ~n~  ~n~  ~n~  ~n~  ~n~ ~n~  ~n~ ~n~ ~r~ %s ~w~ is now back.", name);
  90.     GameTextForAll(back,4000,3);
  91.     IsPlayerAfk[playerid] = 0;
  92.     return true;
  93.     }
  94.     if (IsPlayerAfk[playerid] == 0) {
  95.     SendClientMessage(playerid, COLOR_RED, "ERROR : You arent AFK! Use /afk to be AFK!"); //Anti Spam
  96.     }
  97.     return true;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement