new bool:isAFK[MAX_PLAYERS];
dcmd_afk(playerid, params[])
{
#pragma unused params
if(isAFK[playerid] == false)
{
TogglePlayerControllable(playerid, 0);
isAFK[playerid] = true;
}
else
{
TogglePlayerControllable(playerid, 1);
isAFK[playerid] = false;
}
}
Ahoj, pouћij public "OnPlayerTakeDamage" vice zde: https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
Jednoduљe zkontroluj jestli je afk a pak mu nastav zpět ћivoty, kterй mб mнt. Hi, try using public "OnPlayerTakeDamage" more info: https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage Just check if is player afk and then set back his health bar. |
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID)
{
if(weaponid == 0 && AFK[playerid] == true)
{
new Float:iarmour;
GetPlayerArmour(playerid, iarmour);
if(iarmour > 0)
{
SetPlayerArmour(playerid, amount);
}
else
{
SetPlayerHealth(playerid, amount);
}
}
}
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) { if(issuerid != INVALID_PLAYER_ID) { if(weaponid == 0 && AFK[playerid]) { new Float:iarmour; new Float:ihealth; GetPlayerArmour(playerid, iarmour); GetPlayerHealth(playerid, ihealth); SetPlayerArmour(playerid, iarmour); SetPlayerHealth(playerid, ihealth); } } return 1; }
Why use the toggle, simply set his health so far up that it doesn't drop. And if it does start going down, just set it back up again.
|
Zkus toto:
Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) { if(issuerid != INVALID_PLAYER_ID) { if(weaponid == 0 && AFK[playerid]) { new Float:iarmour; new Float:ihealth; GetPlayerArmour(playerid, iarmour); GetPlayerHealth(playerid, ihealth); SetPlayerArmour(playerid, iarmour); SetPlayerHealth(playerid, ihealth); } } return 1; } |
Because they can go around with endless health while their afk variable is set on true?
Freezing them is the best option. |