Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Toggleable AFK system by suhrab_mujeeb
- Special thanks to FireCat for testing and helping
- You can remove the credits
- */
- // Includes
- #include <a_samp>
- #include <zcmd>
- // Defines, Colors.
- #define COLOR_BLUE 0x0000FFFF
- #define COLOR_RED 0xFF0000FF
- #define COLOR_GREEN 0x008040FF
- #define Version "1.0b"
- // Variables, Bools.
- new
- bool: IsAvailable,
- IsPlayerAFK[MAX_PLAYERS],
- IsPlayerBRB[MAX_PLAYERS],
- Text3D: AFKPlayer[MAX_PLAYERS],
- Text3D: BRBPlayer[MAX_PLAYERS];
- // Functions
- forward SendClientMessageToAllOthers(playerid,color,string[]);
- public SendClientMessageToAllOthers(playerid,color,string[])
- {
- for(new j=0; j<MAX_PLAYERS; j++)
- {
- if(IsPlayerConnected(j) && j != playerid)
- {
- SendClientMessage(j,color,string);
- }
- }
- }
- // Rest of the code
- public OnFilterScriptInit()
- {
- print(" ");
- print(" _____________________________");
- print(" | |");
- print(" |_ Toggleable AFK/BRB System _|");
- print(" |_ Author: suhrab_mujeeb _|");
- printf(" |_ Release: %s _|", Version);
- print(" |_____________________________|");
- print(" ");
- print(" ");
- IsAvailable = true;
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- IsPlayerAFK[playerid] = 0;
- IsPlayerBRB[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- IsPlayerAFK[playerid] = 0;
- IsPlayerBRB[playerid] = 0;
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(IsPlayerAFK[playerid] == 1)
- {
- return SendClientMessage(playerid, COLOR_RED, "How are you supposed to chat if you are Away from the keyboard?");
- }
- else return 1;
- }
- // Commands
- CMD:afk(playerid, params[])
- {
- if(IsAvailable == true)
- {
- if((IsPlayerAFK[playerid] == 0) && (IsPlayerBRB[playerid] == 0))
- {
- new string[128],
- pName[MAX_PLAYER_NAME];
- TogglePlayerControllable(playerid, 0);
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "%s[%d] is now away from keyboard (/afk)", pName, playerid);
- SendClientMessageToAllOthers(playerid, COLOR_BLUE, string);
- SendClientMessage(playerid, COLOR_BLUE, "You're now set as AFK");
- AFKPlayer[playerid] = Create3DTextLabel("Away from keyboard", 0xFFFFFFFF, 0.0, 0.0, 2.0, 40, 0, 0);
- Attach3DTextLabelToPlayer(AFKPlayer[playerid], playerid, 0.0, 0.0, 0.4);
- IsPlayerAFK[playerid] = 1;
- }
- else if((IsPlayerAFK[playerid] == 1) || (IsPlayerBRB[playerid] == 1))
- {
- SendClientMessage(playerid, COLOR_RED, "You are already AFK/BRB");
- }
- }
- else if(IsAvailable == false)
- {
- return SendClientMessage(playerid, COLOR_RED, "The AFK/BRB system is turned off by an Admin");
- }
- return 1;
- }
- CMD:brb(playerid, params[])
- {
- if(IsAvailable == true)
- {
- if((IsPlayerAFK[playerid] == 0) && (IsPlayerBRB[playerid] == 0))
- {
- new string[128],
- pName[MAX_PLAYER_NAME];
- TogglePlayerControllable(playerid, 0);
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "%s[%d] is will be right back (/brb)", pName, playerid);
- SendClientMessageToAllOthers(playerid, COLOR_BLUE, string);
- SendClientMessage(playerid, COLOR_BLUE, "You're now set as BRB");
- BRBPlayer[playerid] = Create3DTextLabel("Be right back", 0xFFFFFFFF, 0.0, 0.0, 2.0, 40, 0, 0);
- Attach3DTextLabelToPlayer(BRBPlayer[playerid], playerid, 0.0, 0.0, 0.4);
- IsPlayerBRB[playerid] = 1;
- }
- else if((IsPlayerAFK[playerid] == 1) || (IsPlayerBRB[playerid] == 1))
- {
- SendClientMessage(playerid, COLOR_RED, "You are already AFK/BRB");
- }
- }
- else if(IsAvailable == false)
- {
- return SendClientMessage(playerid, COLOR_RED, "The AFK/BRB system is turned off by an Admin");
- }
- return 1;
- }
- CMD:back(playerid, params[])
- {
- if(IsPlayerAFK[playerid] == 1)
- {
- new string[128],
- pName[MAX_PLAYER_NAME];
- IsPlayerAFK[playerid] = 0;
- SendClientMessage(playerid, COLOR_BLUE, "You are now back");
- TogglePlayerControllable(playerid, 1);
- Delete3DTextLabel(AFKPlayer[playerid]);
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "%s[%d] is now back from AFK (/back)", pName, playerid);
- SendClientMessageToAllOthers(playerid, COLOR_BLUE, string);
- }
- if(IsPlayerBRB[playerid] == 1)
- {
- new string[128],
- pName[MAX_PLAYER_NAME];
- IsPlayerBRB[playerid] = 0;
- SendClientMessage(playerid, COLOR_BLUE, "You are now back");
- TogglePlayerControllable(playerid, 1);
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "%s[%d] is now back from BRB (/back)", pName, playerid);
- Delete3DTextLabel(BRBPlayer[playerid]);
- SendClientMessageToAllOthers(playerid, COLOR_BLUE, string);
- }
- else if((IsPlayerAFK[playerid] == 0) && (IsPlayerBRB[playerid] ==0))
- {
- SendClientMessage(playerid, COLOR_RED, "You are neither AFK nor BRB");
- }
- return 1;
- }
- CMD:togglesystem(playerid, params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- if(IsAvailable == true)
- {
- IsAvailable = false;
- SendClientMessage(playerid, COLOR_RED, "AFK/BRB set as un-usable");
- }
- else if(IsAvailable == false)
- {
- IsAvailable = true;
- SendClientMessage(playerid, COLOR_GREEN, "AFK/BRB set as usable");
- }
- }
- else
- {
- return 0;
- }
- return 1;
- }
- CMD:afklist(playerid,params[])
- {
- new count = 0,
- string[128],
- pName[MAX_PLAYER_NAME];
- SendClientMessage(playerid, COLOR_GREEN, " ");
- SendClientMessage(playerid, COLOR_GREEN, "___________ |- AFK Players -| ___________");
- SendClientMessage(playerid, COLOR_GREEN, " ");
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- if(IsPlayerAFK[i] == 1)
- {
- GetPlayerName(i, pName,sizeof(pName));
- format(string, sizeof(string), "Player: {99EE22}%s, {992233}ID: {99DDDD}%d", pName, i);
- SendClientMessage(playerid, COLOR_BLUE, string);
- count++;
- }
- }
- }
- if (count == 0)
- {
- SendClientMessage(playerid, COLOR_RED, "Who are you looking for? No one AFK here");
- SendClientMessage(playerid, COLOR_GREEN, " _______________________________________");
- }
- return 1;
- }
- CMD:brblist(playerid,params[])
- {
- new count = 0,
- string[128],
- pName[MAX_PLAYER_NAME];
- SendClientMessage(playerid, COLOR_GREEN, " ");
- SendClientMessage(playerid, COLOR_GREEN, "___________ |- BRB Players -| ___________");
- SendClientMessage(playerid, COLOR_GREEN, " ");
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- if(IsPlayerBRB[i] == 1)
- {
- GetPlayerName(i, pName,sizeof(pName));
- format(string, sizeof(string), "Player: {99EE22}%s, {992233}ID: {99DDDD}%d", pName, i);
- SendClientMessage(playerid, COLOR_BLUE, string);
- count++;
- }
- }
- }
- if (count == 0)
- {
- SendClientMessage(playerid, COLOR_RED, "Who are you looking for? No one BRB here");
- SendClientMessage(playerid, COLOR_GREEN, " _______________________________________");
- }
- return 1;
- }
- CMD:afkcmds(playerid, params[])
- {
- SendClientMessage(playerid, COLOR_BLUE, "__________ |- Toggleable AFK/BRB commands -| __________");
- SendClientMessage(playerid, COLOR_BLUE, "Basic: /afk | /brb | /back");
- SendClientMessage(playerid, COLOR_BLUE, "Lists: /afklist | /brblist");
- if(IsPlayerAdmin(playerid))
- {
- SendClientMessage(playerid, COLOR_RED, " /togglesystem (rcon cmd)");
- }
- return 1;
- }
- CMD:brbcmds(playerid, params[])
- {
- return cmd_afkcmds(playerid, params);
- }
- CMD:brbcmd(playerid, params[])
- {
- return cmd_afkcmds(playerid, params);
- }
- CMD:afkcmd(playerid, params[])
- {
- return cmd_afkcmds(playerid, params);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement