Checking health
#1

Hello i've been working on a anti cheat for health detection if the health does over 99 it sends a msg to admins:

pawn Код:
forward HealthTimer();
public HealthTimer()
{
    new username[MAX_PLAYER_NAME];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerHealth(playerid, 100))
            {
                new string[253], playerid;
                GetPlayerName(i,username,sizeof(username));
                format(string, sizeof(string), "(AntiCheat): %s (%d): Has been detected for health hacks", username, playerid);
                SendMessageToAdmins(red,string);
                hInfo[playerid][HealthHackWarn] += 1;
            }
        }
    }
}
But I don't know if i have written it right, could you please take a look and point out what i've done wrong and where to put stuff! thank you!
Reply
#2

Not sure i might be wrong.

But i think it checks only if he has exactly 100 not more (Not sure)
Reply
#3

pawn Код:
new Float:health;
GetPlayerHealth(i, health);
if(health > 99.0)
{
//>Kick or ban player..
}
Reply
#4

Hmm, M4D It seems to report me for using health hacks when i have under 99 health
Reply
#5


so
pawn Код:
new Float:health;
GetPlayerHealth(i, health);
if(health == 100.0)
{
//>....
}
but this isn't good way to make anti health hack !
you can define new variable and save player health into it
then set a timer and check if someone has more than his variable so he is cheating
else set variable to new player health
Reply
#6

So far that's working, but before my player spawns I get detections of hacks as when you first join the server you have 100 hp, how do i stop this?

Reply
#7

Put that timer into OnPlayerSpawn because before your player does that I guess it does have 200 Health Points, Or you can put it in OnGameModeInIt and edit your function, Make work only with spawned players.
Reply
#8

Still does it even when timers onplayerspawn
Reply
#9

Hello LeXuZ,

You could use the GetPlayerState https://sampwiki.blast.hk/wiki/Playerstates function.

Quote:

new playerState = GetPlayerState(i);

if(playerState != PLAYER_STATE_NONE)
{
// ...
}

Reply
#10

Quote:
Originally Posted by Clad
Посмотреть сообщение
Put that timer into OnPlayerSpawn because before your player does that I guess it does have 200 Health Points, Or you can put it in OnGameModeInIt and edit your function, Make work only with spawned players.
that's not good that set timer into onplayerspawn because if 100 players join server 100 timers will start and it's not good
but "Make work only with spawned players." it's the good way !

@LeXuZ just make a variable or use PVars ! when player spawn set it 1
for example

pawn Код:
new Spawned[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
Spawned[playerid] = 1;
return 1;
}
and in check callback

pawn Код:
if(health > 99.0 && Spawned[i] == 1)
//then...
make sure you always have to set player health 99
(OnPlayerSpawn , before Spawned[playerid] = 1; )

good luck
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)