OnPlayerGiveDamage bugged?
#1

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?
Reply
#2

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.
Reply
#3

You can't set negative values to armour.
Reply
#4

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.
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)