Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- new AFK[MAX_PLAYERS];
- new Text3D:AFKL[MAX_PLAYERS];
- public OnPlayerConnect(playerid)
- {
- AFK[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- Delete3DTextLabel(AFKL[playerid]);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new string[256];
- if (strcmp("/afklist", cmdtext, true) == 0)
- {
- SendClientMessage(playerid, 0x33AA33AA, "AFK LIST:");
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(AFK[i] == 1)
- {
- new name[128];
- GetPlayerName(i,name,128);
- format(string, 256, "%s", name);
- SendClientMessage(playerid, 0xFFFF00FF, string);
- }
- }
- }
- return 1;
- }
- if(!strcmp(cmdtext, "/AFK", true))
- {
- new string[128], name[MAX_PLAYER_NAME];
- if(AFK[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF, "You are already AFK!");
- GetPlayerName(playerid, name, sizeof name);
- AFK[playerid] = 1;
- TogglePlayerControllable(playerid, 0);
- SendClientMessage(playerid, 0x33AA33AA, "You are now AFK, When you are back type /back!");
- format(string, sizeof string, "%s is now AFK!", name);
- SendClientMessageToAll(0xAFAFAFAA, string);
- AFKL[playerid] = Create3DTextLabel("Away From Keyboard", 0xFF0000FF, 30.0, 40.0, 50.0, 40.0, 0);
- Attach3DTextLabelToPlayer(AFKL[playerid], playerid, 0.0, 0.0, 0.7);
- return 1;
- }
- if(!strcmp(cmdtext, "/BACK", true))
- {
- new string[128], name[MAX_PLAYER_NAME];
- if(AFK[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You aren't AFK!");
- GetPlayerName(playerid, name, sizeof name);
- AFK[playerid] = 0;
- TogglePlayerControllable(playerid, 1);
- SendClientMessage(playerid, 0x33AA33AA, "You are back!");
- format(string, sizeof string, "%s is back!", name);
- SendClientMessageToAll(0xAFAFAFAA, string);
- Delete3DTextLabel(AFKL[playerid]);
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement