Something like this ?
PHP код:
if(strcmp(cmdtext,"/afk",true)==0)
{
if(IsPlayerConnected(playerid))
{
{
if(afk[playerid] == 0)
{
if(AfkTimerTimer[playerid]) return SendClientMessage(playerid,COLOR_GREY," You must wait 3 seconds before using that again !");
GetPlayerPos(playerid, PlayerPosition[playerid][PosX], PlayerPosition[playerid][PosY], PlayerPosition[playerid][PosZ]);
AfkTimerTimer[playerid] = 1;
SendClientMessage(playerid, COLOR_GREY,"You must remain in your current position for 10 seconds.");
SetTimerEx("AfkTimer",10*1000,0,"i",playerid);
return 1;
}
else
{
SetPlayerColor(playerid, TCOLOR_WHITE);
format(string, sizeof(string), "[AdmWarning]: %s Is no longer AFK",PlayerName(playerid));
ABroadCast(COLOR_YELLOW,string,1);
SetPlayerHealth(playerid, 30);
AfkTimerTimer[playerid] = 0;
Delete3DTextLabel(AFKLabel[playerid]);
SendClientMessage(playerid, COLOR_GREY, "You are no longer in AFK mode, and you are now able to move again!");
TogglePlayerControllable(playerid, 1);
afk[playerid] = 0;
return 1;
}
}
}
return 1;
}
And
PHP код:
public AfkTimer(playerid)
{
if(!IsPlayerConnected(playerid)) return 0;
if(AfkTimerTimer[playerid])
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(PlayerPosition[playerid][PosX] == X && PlayerPosition[playerid][PosY] == Y && PlayerPosition[playerid][PosZ] == Z)
{
SetPlayerColor(playerid, TCOLOR_LIGHTGREEN);
SetPlayerHealth(playerid, 999);
AFKLabel[playerid] = Create3DTextLabel("Player is AFK",0x008B00FF,0,0,0,50,-1,1);
Attach3DTextLabelToPlayer(AFKLabel[playerid], playerid, 0,0,0);
SendClientMessage(playerid, COLOR_GREY, "You are now AFK, and you are not able to move.(type /afk to exit the AFK mode)");
TogglePlayerControllable(playerid, 0);
afk[playerid] = 1;
AfkTimerTimer[playerid] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "You are now AFK.");
}
else
{
AfkTimerTimer[playerid] = 0;
SendClientMessage(playerid, COLOR_GREY, " You have moved from your position !");
}
}
return 1;
}
And at the Top :
PHP код:
forward AfkTimer(playerid);