15.01.2011, 17:57
Here's a little and simple code.
At the top of your script:
Under OnPlayerConnect(playerid)
Under OnPlayerCommandText(playerid, cmdtext[])
At the top of your script:
pawn Код:
new IsPlayerAFK[MAX_PLAYERS];
pawn Код:
IsPlayerAFK[playerid] = 0;
pawn Код:
new string[128], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if(strcmp("/afk", cmdtext, true, 4) == 0)
{
if(!IsPlayerAFK[playerid])
{
format(string, sizeof(string), "** [ID: %d] %s is now AFK.",playerid,PlayerName);
SendClientMessageToAll(0xFFFFFFAA, string);
TogglePlayerControllable(playerid,0);
IsPlayerAFK[playerid] = 1;
}
else
{
format(string, sizeof(string), "** [ID: %d] %s is no longer AFK.",playerid,PlayerName);
SendClientMessageToAll(0xFFFFFFAA, string);
TogglePlayerControllable(playerid,1);
IsPlayerAFK[playerid] = 0;
}
return 1;
}