Advertisement
DeWilX

Simple AFK System [0.4]

Apr 30th, 2011
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.08 KB | None | 0 0
  1. /* Simple AFK System by DeWilX */
  2.  
  3. #define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6.  
  7. #define COLOR_YELLOW 0xFFFF00AA
  8. #define COLOR_RED 0xFF0000FF
  9.  
  10. new gPlayers[MAX_PLAYERS][MAX_PLAYER_NAME+1];
  11. new hp = 9999999;
  12. new Float:phealth;
  13. new IsPlayerAfk[MAX_PLAYERS];
  14.  
  15. public OnFilterScriptInit()
  16. {
  17.     print("\n--------------------------------------");
  18.     print(" DeWilX's Simple AFK System -- Loaded");
  19.     print("--------------------------------------\n");
  20.     return 1;
  21. }
  22.  
  23. public OnPlayerConnect(playerid)
  24. {
  25.     IsPlayerAfk[playerid] = 0;
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerDisconnect(playerid, reason)
  30. {
  31.     IsPlayerAfk[playerid] = 0;
  32.     return 1;
  33. }
  34.  
  35. public OnPlayerText(playerid, text[])
  36. {
  37.     if(IsPlayerAfk[playerid] == 1)
  38.         {
  39.         SendClientMessage(playerid, COLOR_RED, "ERROR : You can not use chat when you're AFK. Use /back to be back!");
  40.         return 0;
  41.         }
  42.     return 1;
  43. }
  44.  
  45. public OnPlayerCommandText(playerid, cmdtext[])
  46. {
  47. if (strcmp("/afk", cmdtext, true, 10) == 0)
  48. {
  49.     new string[33];
  50.     if (IsPlayerAfk[playerid] == 0) {
  51.     GetPlayerName(playerid,gPlayers[playerid],MAX_PLAYER_NAME);
  52.     GetPlayerHealth(playerid,phealth);
  53.     SetPlayerHealth(playerid,hp);
  54.     TogglePlayerControllable(playerid, 0);
  55.     format(string,sizeof(string),"<<<[%s] is afk!>>>",gPlayers[playerid]);
  56.     SendClientMessageToAll(COLOR_RED,string);
  57.     IsPlayerAfk[playerid] = 1;
  58.     return true;
  59.     }
  60.     if (IsPlayerAfk[playerid] == 1) {
  61.     SendClientMessage(playerid, COLOR_RED, "ERROR : You are alredy AFK! Use /back to be back!");
  62.     }
  63.     return true;
  64. }
  65. if (strcmp("/back", cmdtext, true, 10) == 0)
  66. {
  67.     new string[33];
  68.     if (IsPlayerAfk[playerid] == 1) {
  69.     TogglePlayerControllable(playerid, 1);
  70.     SetPlayerHealth(playerid,phealth);
  71.     format(string,sizeof(string),"<<<[%s] is back!>>>",gPlayers[playerid]);
  72.     SendClientMessageToAll(COLOR_YELLOW,string);
  73.     IsPlayerAfk[playerid] = 0;
  74.     return true;
  75.     }
  76.     if (IsPlayerAfk[playerid] == 0) {
  77.     SendClientMessage(playerid, COLOR_RED, "ERROR : You arent AFK! Use /afk to be AFK!");
  78.     }
  79.     return true;
  80. }
  81. return 1;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement