[Tutorial] How to prevent damage
#6

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Basically this:
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
        new Float:Health;
	
	GetPlayerHealth(damagedid, Health);
	
	if(playerid != INVALID_PLAYER_ID)
	{
		SetPlayerHealth(damagedid, Health);
	}
    
    return 1;
}
That code just reverses the damage, and it doesn't work, look at this example:
Say the player that got hit has 30 HP.
The damage dealt was 40, killing the player.
Then the callback is called with your code which sets his health back to 30, but he's already dead because the callback is called after the damage is already done.
Reply


Messages In This Thread
How to prevent damage - by Manyula - 04.05.2016, 10:47
Re: How to prevent damage - by Wolfe - 04.05.2016, 11:54
Re: How to prevent damage - by CalvinC - 04.05.2016, 12:14
Re: How to prevent damage - by Wolfe - 04.05.2016, 12:17
Re: How to prevent damage - by F1N4L - 04.05.2016, 12:25
Re: How to prevent damage - by CalvinC - 04.05.2016, 12:33
Re: How to prevent damage - by F1N4L - 04.05.2016, 12:45
Re: How to prevent damage - by SyS - 04.05.2016, 14:45
Re: How to prevent damage - by Manyula - 04.05.2016, 16:19

Forum Jump:


Users browsing this thread: 2 Guest(s)