Limiting Player's health. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Limiting Player's health. (
/showthread.php?tid=618705)
Limiting Player's health. -
StrikerZ - 09.10.2016
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?
Re: Limiting Player's health. -
SickAttack - 09.10.2016
Yeah, hook SetPlayerHealth so if it's over 99.0 then set it to 99.0 (take in consideration vending machines and so on).
Re: Limiting Player's health. -
StrikerZ - 09.10.2016
Is there any way that keeps updating the player with the health? public OnPlayerUpdate?
Re: Limiting Player's health. -
gurmani11 - 09.10.2016
OnPlayerUpdate can cause massive lag, it needs to be handled carefully, but who gives a damn about it when we have taking and giving damage callbacks..
Код:
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;
}
Re: Limiting Player's health. -
StrikerZ - 09.10.2016
Managed to make it but it will be sent only 1 time using sendtoadmin. Right? But anticheat keeps sending the warning message repeatly. How can i make it to keep sending the message repeatly?What i did is this.
Код:
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;
}
Re: Limiting Player's health. -
StrikerZ - 09.10.2016
And this procedure applies same for the weapons?
Re: Limiting Player's health. -
Rdx - 09.10.2016
Your code will spam admins chat on every move he will do.
Try this one:
Код:
stock _SetPlayerHealth(playerid, health)
{
if(health >= 100)
{
SetPlayerHealth(playerid, 99));
}
}
#define SetPlayerHealth(%0,%1) _SetPlayerHealth(%0, %1)