Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Torran's AFK System
- // Made by Torran
- // DO NOT REMOVE THESE CREDITS
- #include <a_samp>
- #include <zcmd>
- #define COLOR_YELLOW 0xFFFF00FF
- #define COLOR_RED 0xFF0000FF
- forward afk_OnPlayerConnect(playerid);
- forward afk_OnPlayerDisconnect(playerid);
- forward afk_OnPlayerText(playerid, text[]);
- new playerAFK[MAX_PLAYERS];
- new Text3D:AFKLabel[MAX_PLAYERS];
- public afk_OnPlayerConnect(playerid)
- {
- playerAFK[playerid] = 0;
- return 1;
- }
- public afk_OnPlayerDisconnect(playerid)
- {
- Delete3DTextLabel(AFKLabel[playerid]);
- return 1;
- }
- public afk_OnPlayerText(playerid, text[])
- {
- if(playerAFK[playerid] == 1)
- {
- SendClientMessage(playerid, COLOR_RED, "You cannot speak while AFK, To talk again please type /back");
- return 0;
- }
- return 1;
- }
- CMD:afk(playerid, params[])
- {
- new string[128], name[MAX_PLAYER_NAME];
- if(playerAFK[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You are already AFK");
- GetPlayerName(playerid, name, sizeof name);
- playerAFK[playerid] = 1;
- TogglePlayerControllable(playerid, 0);
- SendClientMessage(playerid, COLOR_YELLOW, "You are now AFK, When back please type /back");
- format(string, sizeof string, "%s is now AFK", name);
- SendClientMessageToAll(COLOR_YELLOW, string);
- AFKLabel[playerid] = Create3DTextLabel("I am AFK", COLOR_RED, 30.0, 40.0, 50.0, 40.0, 0);
- Attach3DTextLabelToPlayer(AFKLabel[playerid], playerid, 0.0, 0.0, 0.7);
- return 1;
- }
- CMD:back(playerid, params[])
- {
- new string[128], name[MAX_PLAYER_NAME];
- if(playerAFK[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You arent AFK");
- GetPlayerName(playerid, name, sizeof name);
- playerAFK[playerid] = 0;
- TogglePlayerControllable(playerid, 1);
- SendClientMessage(playerid, COLOR_YELLOW, "You are now back");
- format(string, sizeof string, "%s is now back", name);
- SendClientMessageToAll(COLOR_YELLOW, string);
- Delete3DTextLabel(AFKLabel[playerid]);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment