new hh; //write this up
//this under AFK CMD
hh = GetPlayerHealth(playerid);
//then
//under back CMD
SetPlayerHealth(playerid, hh);
store the health to a variable example
PHP код:
|
new Float:afkHealth[MAX_PLAYER]
// AFK CMD | Get player health :
GetPlayerHealth(playerid, afkHealth[playerid]);
// Restore health
SetPlayerHealth(playerid, afkHealth[playerid]);
Like this ?
PHP код:
|
Like this ?
PHP код:
|
new Float:afkHealth[MAX_PLAYERS]
// AFK CMD | Get player health :
GetPlayerHealth(playerid, afkHealth[playerid]);
// Restore health
SetPlayerHealth(playerid, afkHealth[playerid]);
CMD:afk(playerid,params[])
{
if( pInfo[playerid][Spawned] != 1)
{
ShowMessage(playerid, red, 9);
return 1;
}
else
{
GetPlayerHealth(playerid, afkH[playerid]);
TogglePlayerControllable(playerid,0);
GetPlayerArmour(playerid, afkA[playerid]);
SetPlayerHealth(playerid,300000);
SetPlayerArmour(playerid,100000);
AFK[playerid]++;
SetTimer("AFKCheck",1000,1);
}
return 1;
}
CMD:back(playerid,params[])
{
if( pInfo[playerid][Spawned] != 1)
{
ShowMessage(playerid, red, 9);
return 1;
}
else
{
TogglePlayerControllable(playerid,1);
SetPlayerHealth(playerid, afkH[playerid]);
SetPlayerArmour(playerid, afkA[playerid]);
SendClientMessage(playerid,red,"Your status has been set to Playing.");
AFK[playerid] =0;
}
return 1;
forward AFKCheck(playerid);
public AFKCheck(playerid)
{
if(AFK[playerid] == 60)
{
AFK[playerid] = 0;
format(astring,sizeof(astring),"Andre[BOT]: Player %s has been kicked. [Reason: Inactivity ]",GetName(playerid));
SendClientMessageToAll(yellow,astring);
SetTimerEx("KickPlayer",200,false,"d", playerid);
}
}
}
CMD:afk(playerid,params[])
{
if(pInfo[playerid][Spawned] != 1)
{
ShowMessage(playerid, red, 9);
return 1;
}
else
{
GetPlayerHealth(playerid, afkH[playerid]);
TogglePlayerControllable(playerid,0);
GetPlayerArmour(playerid, afkA[playerid]);
SetPlayerHealth(playerid,300000);
SetPlayerArmour(playerid,100000);
AFK[playerid]++;
SetTimerEx("AFKCheck", 60000,false,"i", playerid);
return 1;
}
}
CMD:back(playerid,params[])
{
if(pInfo[playerid][Spawned] != 1)
{
ShowMessage(playerid, red, 9);
return 1;
}
else
{
TogglePlayerControllable(playerid,1);
SetPlayerHealth(playerid, afkH[playerid]);
SetPlayerArmour(playerid, afkA[playerid]);
SendClientMessage(playerid,red,"Your status has been set to Playing.");
AFK[playerid] = 0;
return 1;
}
}
forward AFKCheck(playerid);
public AFKCheck(playerid)
{
if(AFK[playerid] == 1)
{
AFK[playerid] = 0;
format(astring,sizeof(astring),"Andre[BOT]: Player %s has been kicked. [Reason: Inactivity ]",GetName(playerid));
SendClientMessageToAll(yellow,astring);
SetTimerEx("KickPlayer",200,false,"d", playerid);
return 1;
}
else return printf("[Error] Can't check the afk status of %s (ID:%i)", GetName(playerid), playerid);
}