30.06.2017, 18:41
I made this auto afk system as you can see below and i want it to check if the player is afk ,onduty, jailed or logged in as rcon admin, it will only do what it is told as shown below. But if the player is offduty, not jailed, afk or is an rcon admin it should do as told below.. The problem is it wont send the messages and when the player returns they are automatically killed.
PHP код:
public OnPlayerPause(playerid)
{
if(Afk[playerid] == 0)
{
if(IsPlayerAdmin(playerid) || pInfo[playerid][OnDuty] == 1 || pInfo[playerid][Jailed] >= 1 || pInfo[playerid][OnhDuty] == 1)
{
SendClientMessage(playerid, grey,"[AFK]: Your status has been Automatically set to Paused.");
afklabel[playerid] = Create3DTextLabel("Player is Away [AFK]", 0xFFFF00FF, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(afklabel[playerid], playerid, 0.0, 0.0, 0.7);
Afk[playerid] = 1;
}
}
else
{
SendClientMessage(playerid, grey,"[AFK]: Your status has been Automatically set to Paused.");
SendClientMessage(playerid, grey,"[AFK]: You have 10 minutes to return or you will be kicked get kick.");
AFKtimer = SetTimerEx("AFK", 600000, 0, "i", playerid);
afklabel[playerid] = Create3DTextLabel("Player is Away [AFK]", 0xFFFF00FF, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(afklabel[playerid], playerid, 0.0, 0.0, 0.7);
Afk[playerid] = 1;
GetPlayerHealth(playerid, afkH[playerid]);
SetPlayerHealth(playerid,300000);
GetPlayerArmour(playerid, afkA[playerid]);
SetPlayerArmour(playerid,100000);
TogglePlayerControllable(playerid,0);
}
return 1;
}
public OnPlayerResume(playerid, time)
{
Return(playerid);
KillTimer(AFKtimer);
new string[48];
format(string, sizeof(string), "[AFK]: Welcome Back, you were paused for %i milliseconds.", time);
SendClientMessage(playerid, coolblue, string);
return 1;
}
stock Return(playerid)
{
Afk[playerid] = 0;
SetPlayerHealth(playerid, afkH[playerid]);
SetPlayerArmour(playerid, afkA[playerid]);
TogglePlayerControllable(playerid,1);
Delete3DTextLabel(afklabel[playerid]);
}