EnzoMetlc

AFK system

Jul 26th, 2013 (edited)
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.71 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define COLOR_RED       0xF10000FF
  4. #define COLOR_GREEN     0x006500FF
  5. #define COLOR_BLUE      0x000071FF
  6. #define COLOR_ORANGE    0xBF6500FF
  7.  
  8. new bool isPlayerAFK[MAX_PLAYERS];
  9.  
  10. public OnPlayerCommandText(playerid, cmdtext[])
  11. {
  12.     if(!strcmp(cmdtext, "/afk", true))
  13.     {
  14.         if(isPlayerAFK[playerid] == true) return SendClientMessage(playerid, COLOR_RED, "You're already in AFK mode!");
  15.  
  16.         new str[128], name[MAX_PLAYER_NAME];
  17.         GetPlayerName(playerid, NombreJugador, MAX_PLAYERS);
  18.         format(str, sizeof(str), "%s entered AFK mode.", name);
  19.  
  20.         SendClientMessage(playerid, COLOR_ORANGE, "You're now in AFK mode.");
  21.         SendClientMessage(playerid, COLOR_ORANGE, "Type /exitafk to get back.");
  22.         SendClientMessageToAll(COLOR_BLUE, str);
  23.  
  24.         SetPlayerVirtualWorld(playerid, 6);
  25.         TogglePlayerControllable(playerid, 0);
  26.         isPlayerAFK[playerid] = true;
  27.         return 1;
  28.     }
  29.  
  30.     if(!strcmp(cmdtext, "/exitafk", true))
  31.     {
  32.         if(isPlayerAFK[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "You are not in AFK mode!");
  33.        
  34.         new str[128], name[MAX_PLAYER_NAME];
  35.         GetPlayerName(playerid, name, MAX_PLAYERS);
  36.         format(string, sizeof(string), "%s exited AFK mode", name);
  37.         SendClientMessageToAll(COLOR_ORANGE, string);
  38.  
  39.         SetPlayerVirtualWorld(playerid, 0);
  40.         TogglePlayerControllable(playerid, 1);
  41.         isPlayerAFK[playerid] = false;
  42.         return 1;
  43.     }
  44.     return 0;
  45. }
  46.  
  47. public OnPlayerText(playerid, text[])
  48. {
  49.     if(isPlayerAFK[playerid] == true) SendClientMessage(playerid, COLOR_RED, "You can't chat while AFK. Type /exitafk.");
  50.     return 0;
  51. }
  52.  
Add Comment
Please, Sign In to add comment