Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define COLOR_RED 0xF10000FF
- #define COLOR_GREEN 0x006500FF
- #define COLOR_BLUE 0x000071FF
- #define COLOR_ORANGE 0xBF6500FF
- new bool isPlayerAFK[MAX_PLAYERS];
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/afk", true))
- {
- if(isPlayerAFK[playerid] == true) return SendClientMessage(playerid, COLOR_RED, "You're already in AFK mode!");
- new str[128], name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, NombreJugador, MAX_PLAYERS);
- format(str, sizeof(str), "%s entered AFK mode.", name);
- SendClientMessage(playerid, COLOR_ORANGE, "You're now in AFK mode.");
- SendClientMessage(playerid, COLOR_ORANGE, "Type /exitafk to get back.");
- SendClientMessageToAll(COLOR_BLUE, str);
- SetPlayerVirtualWorld(playerid, 6);
- TogglePlayerControllable(playerid, 0);
- isPlayerAFK[playerid] = true;
- return 1;
- }
- if(!strcmp(cmdtext, "/exitafk", true))
- {
- if(isPlayerAFK[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "You are not in AFK mode!");
- new str[128], name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, MAX_PLAYERS);
- format(string, sizeof(string), "%s exited AFK mode", name);
- SendClientMessageToAll(COLOR_ORANGE, string);
- SetPlayerVirtualWorld(playerid, 0);
- TogglePlayerControllable(playerid, 1);
- isPlayerAFK[playerid] = false;
- return 1;
- }
- return 0;
- }
- public OnPlayerText(playerid, text[])
- {
- if(isPlayerAFK[playerid] == true) SendClientMessage(playerid, COLOR_RED, "You can't chat while AFK. Type /exitafk.");
- return 0;
- }
Add Comment
Please, Sign In to add comment