OnPlayerTakeDamage
#1

I'm having some issues with my OnPlayerTakeDamage when being shot it only takes away the health and it completely ignores the Armour. Thanks for the help in advance.
Its from this script btw: https://sampforum.blast.hk/showthread.php?tid=641235

PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID)
    {
        new
            
Float:health
        
;
        
        
PlayerInfo[playerid][pLastDamagetime] = gettime();
        
GetPlayerHealth(playeridhealth); 
        
        if(
GetPlayerTeam(playerid) != PLAYER_STATE_ALIVE && PlayerInfo[playerid][pDeathFix])
            
SetPlayerHealth(playeridhealth); 
        
        if(
GetPlayerTeam(playerid) == PLAYER_STATE_ALIVE)
        {
            
SetPlayerHealth(playeridhealth amount); 
            
CallbackDamages(playeridissueridbodypartweaponidamount); 
        }
        
        if(
health amount <= 4)
        {
            if(
GetPlayerTeam(playerid) == PLAYER_STATE_ALIVE)
            {
                if(
IsPlayerInAnyVehicle(playerid))
                    
ClearAnimations(playerid); 
                
                
CallLocalFunction("OnPlayerWounded""iii"playeridissueridweaponid); 
                return 
0;
            }
            
            return 
0;
        }
        
        if(
GetPlayerTeam(playerid) == PLAYER_STATE_WOUNDED)
        {
            if(!
PlayerInfo[playerid][pDeathFix])
            {                
                
CallLocalFunction("OnPlayerDead""iiii"playeridissueridweaponid1);
                return 
0;
            }
            
            return 
0;
        }
        
        if(
GetPlayerTeam(playerid) != PLAYER_STATE_ALIVE)
        {
            
SetPlayerHealth(playeridhealth);
            return 
0;
        }
    }
    return 
1;

Reply
#2

I forgot to account for armor. I posted code for it when someone pointed it out.

PHP код:
new 
    
playerArmor
    
amoun;  
     
GetPlayerArmour(playeridplayerArmor);  
if(
GetPlayerTeam(playerid) == PLAYER_STATE_ALIVE

    if(
playerArmor 0// if their armor is greater than 0 
    

        
amoun playerArmor amount// player's armor - amount of damage taken  
         
        
if(amoun <= 0// if armor - amount taken is less than or equal to 0  
            
SetPlayerHealth(playeridplayerHealth amount); // health is set 
             
        
else 
        { 
            if(
bodypart != BODY_PART_HEAD && bodypart != BODY_PART_RIGHT_LEG && bodypart != BODY_PART_LEFT_LEG
                
SetPlayerArmour(playeridamoun); // if the bodypart doesn't equal head, left/right leg, we'll set their armor down 
                 
            
else SetPlayerHealth(playeridplayerHealth amount); // else their armor is taken down 
        

    } 
    else 
SetPlayerHealth(playeridplayerHealth amount); 

http://forum.sa-mp.com/showpost.php?...3&postcount=59
Reply
#3

Why don't you use SetPlayerArmour?

E: Nvm, my bad.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)