09.10.2016, 06:11
Hi there. Is there a way to limit the health of all players to 99.0 because im making an anti cheat and when player has 100 then it could be a possible health hack. Is there any way to limit the health to 99.0?
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID) // ensure that issuer is not invalid
{
new Float:Health;
GetPlayerHealth(playerid, Health); // saved the current health
if(amount > 99.0) // checked the amount if its above 99.0
SetPlayerHealth(playerid, 99.0); // then set it back to 99.0
else
SetPlayerHealth(playerid, Health + amount); // otherwise give the player the same amount which is taken from him by issuer
}
return 1;
}
public OnPlayerUpdate(playerid)
{
new Float:Health2;
if(GetPlayerHealth(playerid, Health2) >= 100)
{
new string[120];
format(string, sizeof(string), "%s is health hacking.(Server player health: 99, Player health: %d)", PN(playerid), GetPlayerHealth(playerid, Health2));
SendToAdmins(COLOR_RED, string);
}
return 1;
}
stock _SetPlayerHealth(playerid, health)
{
if(health >= 100)
{
SetPlayerHealth(playerid, 99));
}
}
#define SetPlayerHealth(%0,%1) _SetPlayerHealth(%0, %1)