SA-MP Forums Archive
OnPlayerGiveDamage bugged? - 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: OnPlayerGiveDamage bugged? (/showthread.php?tid=346007)



OnPlayerGiveDamage bugged? - ombre - 27.05.2012

Hi,

I use this code:

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
{
    if(damagedid != INVALID_PLAYER_ID)
    {
    	        new Float:Health,Float:Armour;
	   	GetPlayerHealth(damagedid,Health);
	   	GetPlayerArmour(damagedid,Armour);
	   	if(Armour > 0)
	        {
       		switch(weaponid)
       		{
       		    case 24: return SetPlayerArmour(damagedid,Armour-20);
				default: return 1;
	        }
                }
    }
    return 1;
}
When I shoot on a player, he should forfeit 46(gta domage) +20 = 66hp but sometime he lost 66hp sometime 20hp and sometime he's ban for armor cheat with 249 hp.

This function it is not very precise?


Re: OnPlayerGiveDamage bugged? - admantis - 27.05.2012

That's because if an armor value is invalid (below 0) it will set it to 255. Ensure the armour is over 20, and not over 0, because if your armor was 10, it would be (10-20), resulting -10, resulting armor being set to 255.


Re: OnPlayerGiveDamage bugged? - Face9000 - 27.05.2012

You can't set negative values to armour.


Re : OnPlayerGiveDamage bugged? - ombre - 27.05.2012

you'r really sure? Why it's sometime return 249hp? Why when I shoot the damage is not always identical? I don't find a good FS for real/modif damage.


Re : OnPlayerGiveDamage bugged? - ombre - 27.05.2012

For my test I am always close to the victim. The problem of the damage inflicted is not the position but the return of OnPlayerGiveDamage. Sometimes it give damage gta+20 sometimes just 20.