Disabling damange once reaching a certain amount
#6

Quote:
Originally Posted by Zmith
View Post
I haven't tested it ingame, but it should work I guess.

PHP Code:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    new 
Float:HP;
    
GetPlayerHealth(playeridHP);
    if(
HP == 5)
    {
        
SetPlayerHealth(playerid5);//If this doesn't work, you could set the player's health -1 and create a timer to set it back to 5.
    
}
    return 
1;

First, you are checking for exactly 5hp, not less or equal, second you are setting player HP to 5 not to what it was. Third, if im not wrong GetPlayerHealth in these case will return new health (after the hit was processed). And whole public is not meant to be used for these. If player has 15hp, he gets hit by deagle, he will lose all HP and die before server has time to restore it.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)