Код:
#include <a_samp>
#define COLOR_RED 0xFF0000AA
#define COLOR_GREY 0xC0C0C0AA
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Idea By DR.Lozer | Creator: ReD_Boii1");
print("--------------------------------------\n");
return 1;
}
enum pinfo {
AFK,
Float:Px,
Float:Py,
Float:Pz,
};
new PlayerInfo[MAX_PLAYERS][pinfo];
PlayerName(playerid)
{
new pname[24]; GetPlayerName(playerid, pname,24);
return pname;
}
public OnPlayerText(playerid, text[])
{
if(PlayerInfo[playerid][AFK] == 1)
{
SendClientMessage(playerid, COLOR_RED,"ERROR: Your AFk You Cant Talk");
return 0;
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[128];
if (strcmp("/afk", cmdtext, true, 10) == 0)
{
if(PlayerInfo[playerid][AFK] == 1) return SendClientMessage(playerid, COLOR_RED,"ERROR: Your Already AFK");
PlayerInfo[playerid][AFK] = 1;
TogglePlayerControllable(playerid, 0);
GameTextForPlayer(playerid,"~r~AFK",1000,1);
format(string,128,"%s is now AFK",PlayerName(playerid));
SendClientMessageToAll(COLOR_GREY,string);
return 1;
}
if (strcmp("/back", cmdtext, true, 10) == 0)
{
if(PlayerInfo[playerid][AFK] == 0) return SendClientMessage(playerid, COLOR_RED,"ERROR: Your not AFK");
PlayerInfo[playerid][AFK] = 0;
TogglePlayerControllable(playerid, 1);
GameTextForPlayer(playerid,"~r~AFK BACK",1000,1);
format(string,128,"%s is Back From AFK",PlayerName(playerid));
SendClientMessageToAll(COLOR_GREY,string);
return 1;
}
if (strcmp("/afklist", cmdtext, true, 10) == 0)
{
new Count = 0;
for(new i = 0; i< MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[playerid][AFK] == 1) Count++;
if(Count <= 0) return SendClientMessage(playerid, COLOR_RED,"No one is afk");
format(string,128,"There Are %d Afk Player",Count);
SendClientMessage(playerid, COLOR_RED,string);
for(new i = 0; i< MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[playerid][AFK] == 1) {
format(string,128,"%s (%d) AFK",PlayerName(i),i);
SendClientMessage(playerid, COLOR_GREY,string);
}
return 1;
}
return 0;
}