Jump to content

OnClientPedDamage not working good :(


redditing

Recommended Posts

function playerDamage_text ( attacker, weapon, bodypart, loss) 
	if ( bodypart == 9 and attacker and attacker ~= source ) then 
		loss = 50
		setElementHealth(chuj, getElementHealth(chuj)-50)
		if getPlayerArmor(chuj)>0 then
			setPedArmor(chuj, getPlayerArmor(chuj)-50)
		end
	end
end
addEventHandler ( "onClientPedDamage", root, playerDamage_text )

 

So the matter is simple, when I shoot in the head of the NPC then he dies immediately, but I want that if I shoot him in the head it takes 50% of his hp, I don't know what's wrong here anyone will help?

Link to comment

try this , and check form NPC reosurce .

?
function playerDamage_text ( attacker, weapon, bodypart, loss) 
      if ( bodypart == 9 and attacker and attacker ~= source ) then 
          local Health , Armor = getElementHealth ( source ) , getPedArmor ( source )
          setElementHealth ( source , Health - 50 )
          outputChatBox ( tostring ( Health )..' ; '.. tostring ( Health - 50 ) )
          if ( Armor > 0 ) then
              setPedArmor ( source , Armor ( source ) - 50 )
          end
      end
end
addEventHandler ( "onClientPedDamage", root, playerDamage_text )
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...