Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #define COLOR_AFK 0xF0CC00FF
- #define COLOR_AFK2 0xE0FFFFAA
- new AFK[MAX_PLAYERS];
- new AFKTimer[MAX_PLAYERS];
- new Text:AFKText[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" AFK Script by BlackSA.");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- AFK[playerid] = 0;
- AFKTimer[playerid] = 0;
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- new string[128];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- if(AFK[playerid])
- {
- format(string, sizeof(string), "[AFK Chat] %s says: %s", name, text);
- AfkC(COLOR_AFK, string);
- return 0;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new string[128];
- new playername[MAX_PLAYER_NAME];
- if (strcmp("/afk", cmdtext, true, 10) == 0)
- {
- TextDrawHideForPlayer(playerid, AFKText[playerid]);
- AFKText[playerid] = TextDrawCreate(150.0, 150.0, "~r~-AFK, To get out of AFK: ~w~/AFK-");
- TextDrawUseBox(AFKText[playerid], 0);
- TextDrawFont(AFKText[playerid], 2);
- GetPlayerName(playerid, playername, sizeof(playername));
- if(AFK[playerid] == 0)
- {
- format(string, sizeof(string), "SERVER: %s is now on AFK mode!", playername);
- SendClientMessageToAll(COLOR_AFK, string);
- TogglePlayerControllable(playerid, 0);
- SetTimerEx("AFKTime", 30000, false, "i", 1337);
- SetPlayerCameraPos(playerid, -833.5241,-1358.8575,86.9054);
- SetPlayerCameraLookAt(playerid, -833.5241,-1358.8575,0);
- TextDrawShowForPlayer(playerid, AFKText[playerid]);
- AFK[playerid] = 1;
- AFKTimer[playerid] = 1;
- }
- else
- {
- if(AFKTimer[playerid]) return SendClientMessage(playerid, COLOR_AFK2, "SERVER: You must wait 30 seconds before exit AFK mode.");
- format(string, sizeof(string), "SERVER: %s is now off AFK mode!", playername);
- SendClientMessageToAll(COLOR_AFK, string);
- TogglePlayerControllable(playerid, 1);
- SetCameraBehindPlayer(playerid);
- AFK[playerid] = 0;
- AFKTimer[playerid] = 0;
- }
- return 1;
- }
- if(strcmp("/afklist", cmdtext, true, 10) == 0)
- {
- for(new i = 0; i<MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(AFK[i])
- {
- SendClientMessage(playerid, COLOR_AFK2, "SERVER: AFK List: ");
- GetPlayerName(i, playername, sizeof(playername));
- format(string, sizeof(string), " %s are on AFK mode.", playername);
- SendClientMessage(playerid, COLOR_AFK, string);
- }
- else
- {
- SendClientMessage(playerid, COLOR_AFK2, "SERVER: There is no peoples are in AFK mode right now.");
- }
- }
- }
- return 1;
- }
- return 0;
- }
- forward AFKTime();
- public AFKTime()
- {
- for(new i = 0; i<MAX_PLAYERS; i++)
- {
- if(AFKTimer[i])
- {
- AFKTimer[i] = 0;
- }
- }
- return 1;
- }
- forward AfkC(color, const string[]);
- public AfkC(color, const string[])
- {
- for(new i = 0; i<MAX_PLAYERS; i++)
- {
- if(AFK[i])
- {
- SendClientMessage(i, color, string);
- TextDrawHideForPlayer(i, AFKText[i]);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement