SA-MP Forums Archive
Anti Health Hack not working. - 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: Anti Health Hack not working. (/showthread.php?tid=487848)



Anti Health Hack not working. - Bartels - 15.01.2014

Hello,

I've been trying to create my own simple anti health hack using the wiki and some tutorials. All it should be doing is check whether or not the player's HP is above a certain level. However in-game nothing really happens when I set my own HP to several different values above the limit.

Код:
	if(PlayerStatus[playerid][dead] == false)
	{
		    //Health
		new Float:HP, string[24];
		GetPlayerHealth(playerid, HP);
		new dots = floatround(floatdiv(HP, 0.8695652173913044), floatround_round);
		for(new i; i < dots; i++) { string[i] = 'l'; }
		TextDrawSetString(PlayerStatus[playerid][Health], string);
		   // My bit
		new Float:hp;
		GetPlayerHealth(playerid, hp);
		if(hp >= 52.0)
		{
    	SendClientMessageToAll(-1, "[DEBUG] Health Hacks Detected");
		}
The first bit is a custom health bar which was in the script by default, that might have something to do with it though. My scripting is the second bit.

Entire OnPlayerUpdate: http://pastebin.com/GgPAvRPk

I have tried putting the code outside of the if(PlayerStatus[playerid][dead] == false), but the chat would just get spammed with false warnings from people not yet spawned.

Any help would be greatly appreciated, this looks like a simple problem to me, however I've asked multiple people and none of them knew the error.


Re: Anti Health Hack not working. - Raza2013 - 15.01.2014

well, i dont think this will works for players
i'm using a little Anti Hack system
pawn Код:
#include <a_samp>
#include <foreach>

new Exception_Health[MAX_PLAYERS]; //on top
//------ forward lacks
forward AntiHealthHack();
new Float:pHealth[MAX_PLAYERS];

//---ongamemodeint

SetTimer("AntiHealthHack", 1000, true);
//-------
public AntiHealthHack()
{
    foreach(Player, i)
    {
        new Float:Health;
        GetPlayerHealth(i, Health);
        if(Health != pHealth[i] && Health > 0)
        {
            if(Health > pHealth[i] && Exception_Health[i] == 0)
            {
                BanEx(i, "Health Hacker");
            }
            else if(Health > pHealth[i] && Exception_Health[i] == 1)
            {
                pHealth[i] = Health;
                Exception_Health[i] = 0;                
            }
        }
    }
    return 1;
}



Re: Anti Health Hack not working. - doreto - 15.01.2014

What you are doing is getting and store player health then few lines below you are getting same health and storing it and compare it to unreasonable value.Solution for this to store player health from last check and compare to new health check. You can follow Raza2013 code and fix it. I will suggest you using 1 second global timer (1000 milliseconds) then OnPlayerUpdate where's been called 20-30 times in 1 second.


Re: Anti Health Hack not working. - Bartels - 15.01.2014

Quote:
Originally Posted by doreto
Посмотреть сообщение
What you are doing is getting and store player health then few lines below you are getting same health and storing it and compare it to unreasonable value.Solution for this to store player health from last check and compare to new health check. You can follow Raza2013 code and fix it. I will suggest you using 1 second global timer (1000 milliseconds) then OnPlayerUpdate where's been called 20-30 times in 1 second.
The maximum health in my server is 50, that's a crucial part of information I forgot to mention. That's where the 52 value comes from. This caused quite a few issues as players had a slight delay in their HP getting set.

However I fixed this by adding the check to OnPlayerDeath instead, only when a hacker kills another player and is using health/armour hacks, he/she will get banned.

Thanks to everyone for their help.


Re: Anti Health Hack not working. - Izaki - 31.05.2016

how fix scipt ?