[Help] Health Anticheat Problem -
viKKmaN - 16.03.2010
I am trying to script a type of health anti-cheat but it just won't work properly...
Код:
//The function below is called every 250ms
public HealthCheck()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && GetPlayerState(i) != PLAYER_STATE_SPECTATING && GetPlayerState(i) != PLAYER_STATE_WASTED)
{
new Float:health;
GetPlayerHealth(i, health);
if(health >= 100.0)
{
SetPlayerHealth(i, 75.0);
GetPlayerHealth(i, health);
if(health > 75.0)
{
SendClientMessage(i, COLOR_RED, "-> Cheater");
}
else
{
SendClientMessage(i, COLOR_RED, "-> Clean");
SetPlayerHealth(i, 100.0);
}
}
}
}
As soon as i enter the server i keep getting "-> Cheater" message.
Normaly i shouldn't get it since i don't hack but i keep getting it.
The code looks like it should work but it just doesn't.
Anyone can figure out the problem?
Re: [Help] Health Anticheat Problem - [03]Garsino - 16.03.2010
Put it under OnPlayerSpawn instead. Since there's no point in hacking health when you're not spawned.
Re: [Help] Health Anticheat Problem -
viKKmaN - 16.03.2010
You didn't get my point... It works exactly as it shouldn't.
EXAMPLE:
Retrieve Health: 100.0
Health Set: 75.0
Retrieve Health: 100.0 // Here is my problem. Second time it retrieves 100.0 health even if i have 75.0 health
Retrieved Health != Health Set -> Cheater
Re: [Help] Health Anticheat Problem -
viKKmaN - 16.03.2010
Quote:
Originally Posted by viKKmaN
You didn't get my point... It works exactly as it shouldn't.
EXAMPLE:
Retrieve Health: 100.0
Health Set: 75.0
Retrieve Health: 100.0 // Here is my problem. Second time it retrieves 100.0 health even if i have 75.0 health
Retrieved Health != Health Set -> Cheater
|
No1?
Re: [Help] Health Anticheat Problem - [03]Garsino - 17.03.2010
When the player join, his health is above 100. I have noticed this myself.
Re: [Help] Health Anticheat Problem -
Chris. - 17.03.2010
I noticed you were missing a bracket.
pawn Код:
//The function below is called every 250ms
public HealthCheck()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && GetPlayerState(i) != PLAYER_STATE_SPECTATING && GetPlayerState(i) != PLAYER_STATE_WASTED)
{
new Float:health;
GetPlayerHealth(i, health);
if(health >= 100.0)
{
SetPlayerHealth(i, 75.0);
GetPlayerHealth(i, health);
if(health > 75.0)
{
SendClientMessage(i, COLOR_RED, "-> Cheater");
}
else
{
SendClientMessage(i, COLOR_RED, "-> Clean");
SetPlayerHealth(i, 100.0);
}
}
}
}
}
See if that helps?
Re: [Help] Health Anticheat Problem -
cessil - 17.03.2010
SetPlayerHealth takes a couple of seconds to work, I came across this problem with my Anti Cheat too.
Re: [Help] Health Anticheat Problem -
XGh0stz - 17.03.2010
Quote:
Originally Posted by cessil
SetPlayerHealth takes a couple of seconds to work, I came across this problem with my Anti Cheat too.
|
He's right, lag is an important issue, so first set the health to 75, then wait a X amount of seconds before checking health again...
X = whatever number best suits to work for you & your players (I suggest starting with 3 though)