0.3z anti health hack? -
newbienoob - 20.01.2014
What do you think about this code? It should detect a health hacker
pawn Код:
new hit[MAX_PLAYERS], Float:oldhealth[MAX_PLAYERS], Float:newhealth[MAX_PLAYERS];
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
switch(hittype)
{
case BULLET_HIT_TYPE_PLAYER:
{
hit[hitid]++;
switch(hit[hitid])
{
case 1..3: GetPlayerHealth(hitid, oldhealth[hitid]);
case 4..6:
{
GetPlayerHealth(hitid, newhealth[hitid]);
if(newhealth[hitid] == oldhealth[hitid])
{
//Ban(playerid); //cheat
SendClientMessage(playerid, -1, "cheat");
}
}
default:hit[hitid] = 0;
}
}
}
return 1;
}
I tested it with server-side godmode(setting player's health to infinite), so far it works. But, I need your opinion. Maybe there's something that I forgot?
Re: 0.3z anti health hack? -
CuervO - 20.01.2014
From a first look it would work however OnPlayerWeaponShot is only called for firearms (Pistols, Shotguns, SMGs, Assault Rifles, Rifles & Minigun). If the hacker was attacked with another weapons other than those ones it would not detect the hack. Also remember that if the player is frozen OnPlayerWeaponShot will still be called and HP would not lower.
Re: 0.3z anti health hack? -
Optimus_Sprite - 20.01.2014
I personally have used the event OnPlayerTakeDamage.
GetPlayerHealth (+ if Armour)> SetPlayerHealth (+ if Armour) taking into account the damage works fine.
Re: 0.3z anti health hack? -
CuervO - 20.01.2014
You can also prevent or change completely the damages if you use this method; Here's an example of functions i've done in the past.
http://pastebin.com/VaS1qSAG
Re: 0.3z anti health hack? -
chencong - 20.01.2014
there like have a simple way..
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
new msg[256],Float:health;
format(msg,256,"OnPlayerGiveDamage: Playerid:%d Damagedid:%d Amount:%f Weaponid:%d Bodypart:%d",playerid,damagedid,amount,weaponid,bodypart);
SendClientMessage(playerid,-1,msg);
GetPlayerHealth(damagedid,health);
SetPlayerHealth(damagedid,health-amount); //Is this can anti health locking cheat?
return 1;
}
I tried to test it with my friend then succeed anti-health locking
Respuesta: 0.3z anti health hack? -
MugiwaraNoLuffy - 20.01.2014
OnPlayerGiveDamage detects melee hits and weapon shots, but not explosions and car collisions.
Re: 0.3z anti health hack? -
cessil - 20.01.2014
what are you doing with the first 2 hits? you do nothing with that oldhealth, the only time it compares is from shot 3 - 4 and the time inbetween could be less than 50ms, which isn't enough for the clients to update getting shot and taking damage.
Re: 0.3z anti health hack? -
Cypress - 20.01.2014
Quote:
Originally Posted by CuervO
You can also prevent or change completely the damages if you use this method; Here's an example of functions i've done in the past.
http://pastebin.com/VaS1qSAG
|
Is your custom damage dealing with players health when they dive in water?
Re: 0.3z anti health hack? -
Riddick94 - 20.01.2014
Quote:
Originally Posted by Cypress
Is your custom damage dealing with players health when they dive in water?
|
Easiest way to do custom damage is to set player team to the global team whenever player joins, and in OnPlayerTakeDamage you can do whatever you want, also it will prevent some weapons (the ones that won't have setted damage) from giving damage.
Re: 0.3z anti health hack? -
newbienoob - 20.01.2014
Quote:
Originally Posted by cessil
what are you doing with the first 2 hits? you do nothing with that oldhealth, the only time it compares is from shot 3 - 4 ...
|
Server will store player's health into the oldhealth variable if players take 2 damages. Like, if they took 1 damage, server will store the health; If they took another damage, server will update the stored health. If they took another damage(3rd damage), server will store player's health into a new variable, newhealth AND we will compare the oldhealth and the newhealth. If they're same, ban.
Quote:
Originally Posted by cessil
and the time inbetween could be less than 50ms, which isn't enough for the clients to update getting shot and taking damage.
|
How bout now?
pawn Код:
new hit[MAX_PLAYERS], Float:oldhealth[MAX_PLAYERS], Float:newhealth[MAX_PLAYERS];
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
switch(hittype)
{
case BULLET_HIT_TYPE_PLAYER:
{
hit[hitid]++;
switch(hit[hitid])
{
case 1..5: GetPlayerHealth(hitid, oldhealth[hitid]); //changed 1..5 instead of 1..3 [can be increased if still not enough]
case 6..10: //changed 4..6 instead of 6..10 [can be increased if still not enough]
{
GetPlayerHealth(hitid, newhealth[hitid]);
if(newhealth[hitid] == oldhealth[hitid])
{
//Ban(playerid); //cheat
SendClientMessage(playerid, -1, "cheat");
}
}
default:hit[hitid] = 0;
}
}
}
return 1;
}