AFK system help
#1

hey so I have an afk system that is working fine but is there is a way that if the player stops moving for a while he goes afk I can set the timer but I need the function here is the code if required:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

    GetPlayerName(playerid, names, sizeof(names));

	if (strcmp("/afk", cmdtext, true, 10) == 0)
	{
		if(IsAfk[playerid]) return SendClientMessage(playerid, 0xADD8E6FF, "You're already in AFK mode.");
		IsAfk[playerid] = 1;
		TogglePlayerControllable(playerid, 0);
	format(string,sizeof(string),"%s is AFK.", names);
	SendClientMessageToAll(0xFFFF00FF, string);
	GetPlayerPos(playerid, X, Y, Z);
	GetPlayerHealth(playerid, health);
	afktext = CreatePlayer3DTextLabel(playerid,"Player is in AFK mode.",0xFF0000FF, X,Y,Z,40.0);
		return 1;
	}
	if (strcmp("/back", cmdtext, true, 10) == 0)
	{
		if(IsAfk[playerid] == 1)
		{
			Afk_Back(playerid);
		}
		else
		SendClientMessage(playerid, 0xFF0000FF, "You're not AFK!.");
		return 1;
	}
	return 0;
}

/*public OnPlayerStateChange(playerid, newstate, oldstate)
{
        if(IsAfk[playerid] == 1)
        {
                Afk_Back(playerid);
        }
        else
           SendClientMessage(playerid, 0xADD8E6FF, "You're not in AFK mode.");
        return 1;
}*/

stock Afk_Back(playerid)
{
        IsAfk[playerid] = 0;
        TogglePlayerControllable(playerid, 1);
    format(string,sizeof(string),"%s is back.", names);
    SendClientMessageToAll(0xFFFF00FF, string);
    DeletePlayer3DTextLabel(playerid, afktext);
    return 1;
}
Reply


Messages In This Thread
AFK system help - by silverms - 09.02.2017, 11:54
Re: AFK system help - by Mic_H - 09.02.2017, 12:43

Forum Jump:


Users browsing this thread: 1 Guest(s)