Health anticheat
#1

Hello, in my server the default hp/armour value is 90, so i made a health/armour anticheat. If a player has more than 91 hp, he's cheating. The problem is: Sometimes players get banned when they spawn because for 1 sec they got 100 hp (even if i set 90 hp/armour on OnPlayerSpawn). Here is the code:

pawn Код:
new Float:phealth;
                new Float:parmour;
                GetPlayerHealth(i, phealth);
                GetPlayerArmour(i, parmour);
                if(phealth >=100 || parmour >=100)
                {
                TotalAutoBan++;
                new pname[24];
                new string[320];
                new jj[128];
                new IP[16];
                GetPlayerName(i, pname, sizeof(pname));
                GetPlayerIp(i, IP, 16);
                format(string, sizeof(string), "** System Ban: %s (%d) has been banned for hp/armour hack (%0.2f hp - %0.2f armour)", pname,i,phealth,parmour);
                format(jj,sizeof(jj),"** Total Cheaters Raped: %d",TotalAutoBan);
                SCMTA(pink,string);
                SCMTA(pink,jj);
                SCM(i,red,"You have been banned by System for hp/armour. If you think this is a mistake, post an unban appeal at www.codsamp.net");
                SCM(i,red,"Don't try to evade the ban otherwise you'll get rangebanned.");
                pInfo[i][Banned] ++;
                new str[64];
                format(str,sizeof(str),"banip %s",IP);
                SendRconCommand(str);
                BanLog(string);
                BanEx(i,string);
                new msg[400];
                format(msg, sizeof(msg), "0,4** System Ban: %s (%d) has been banned for hp/armour hack (%0.2f hp - %0.2f armour) Total Cheaters Raped: %d",pname,i,phealth,parmour,TotalAutoBan);
                IRC_GroupSay(gGroupID, IRC_CHANNEL, msg);
                IRC_GroupSay(gGroupID, IRC_ACHANNEL, msg);
                }
                }
How i can fix this problem? I've SetPlayerHealth/Armour(playerid,90); on OnPlayerSpawn, OnPlayerConnect, OnPlayerRequestClass/Spawn.
Reply
#2

do you use timer to detect it? and how many miles second did you set to detect if player uses hacks?

if you use 1000 miles seconds try increasing it for 3000 - 4000 miles seconds. as it happens to me before. when i set my anti-cheat timer to 1000 miles seconds.
Reply
#3

On Spawn, set an "immune", like set a timer for 10 seconds after spawning.
After that 10 seconds, set a local variable pImmune[playerid] = 1; to 0. onPlayerUpdate or whereever you're checking the health, first check for the immune. This gives the server enough time to set everything right.
Reply
#4

You can fix that with variable.
pawn Код:
new pSpawned[MAX_PLAYERS] = 1;

OnplayerConnect(playerid)
{
pSpawned[playerid] = 0;
return 1;
}

OnPlayerSpawn(playerid)
{
pSpawned[playerid] = 1;
return 1;
}

OnPlayerDeath(playerid)
{
pSpawned[playerid] = 0;
return 1;
}

OnPlayerDisconnect(playerid)
{
pSpawned[playerid] = 0;
return 1;
}

Than just add that in your code

if(phealth >=100 || parmour >=100 && pSpawned[playerid] == 1)
Reply
#5

Quote:
Originally Posted by pds2012
Посмотреть сообщение
do you use timer to detect it? and how many miles second did you set to detect if player uses hacks?

if you use 1000 miles seconds try increasing it for 3000 - 4000 miles seconds. as it happens to me before. when i set my anti-cheat timer to 1000 miles seconds.
Yes, i have a timer for global anticheat. Is every 7000 miles seconds.

Quote:
Originally Posted by judothijs
Посмотреть сообщение
On Spawn, set an "immune", like set a timer for 10 seconds after spawning.
After that 10 seconds, set a local variable pImmune[playerid] = 1; to 0. onPlayerUpdate or whereever you're checking the health, first check for the immune. This gives the server enough time to set everything right.
Okay, thanks

Quote:
Originally Posted by Unknownich
Посмотреть сообщение
You can fix that with variable.
pawn Код:
new pSpawned[MAX_PLAYERS] = 1;

OnplayerConnect(playerid)
{
pSpawned[playerid] = 0;
return 1;
}

OnPlayerSpawn(playerid)
{
pSpawned[playerid] = 1;
return 1;
}

OnPlayerDeath(playerid)
{
pSpawned[playerid] = 0;
return 1;
}

OnPlayerDisconnect(playerid)
{
pSpawned[playerid] = 0;
return 1;
}

Than just add that in your code

if(phealth >=100 || parmour >=100 && pSpawned[playerid] == 1)
I'll try, thanks.
Reply
#6

EDIT: Nothing, same problem. Players spawns and get banned, even with pSpawned check. This happens like 1 of 10th cases, but is boring..see this:

[13:50] <CrazyBot> *** Jeff_Susliks (13) killed TonyZ (15) with TEC-9 - Killer hp/armour (Jeff_Susliks): 65.0 | 0.0
[13:50] <CrazyBet> ** System Ban: TonyZ (15) has been banned for hp/armour hack (100.00 hp - 0.00 armour) Total Cheaters Raped: 285

Players re-spawns and get banned.
Reply
#7

Bump.
Reply
#8

How about setting the 'limit' health as 97 instead of 90? Because for some reason, OnPlayerSpawn, players lose 3 health. Then you can check the 100 HP limit thingy.
Reply
#9

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
How about setting the 'limit' health as 97 instead of 90? Because for some reason, OnPlayerSpawn, players lose 3 health. Then you can check the 100 HP limit thingy.
Are you sure about this?
Reply
#10

where is the code that you provide us located?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)