How to make /afk
#4

Here's a little and simple code.

At the top of your script:
pawn Код:
new IsPlayerAFK[MAX_PLAYERS];
Under OnPlayerConnect(playerid)
pawn Код:
IsPlayerAFK[playerid] = 0;
Under OnPlayerCommandText(playerid, cmdtext[])
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;
}
Reply


Messages In This Thread
How to make /afk - by Dannu13 - 15.01.2011, 17:50
Re: How to make /afk - by Jochemd - 15.01.2011, 17:52
Re: How to make /afk - by Dannu13 - 15.01.2011, 17:56
Re: How to make /afk - by Toreno - 15.01.2011, 17:57

Forum Jump:


Users browsing this thread: 1 Guest(s)