redditing Posted March 31, 2020 Share Posted March 31, 2020 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
^iiEcoo'x_) Posted April 1, 2020 Share Posted April 1, 2020 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
redditing Posted April 1, 2020 Author Share Posted April 1, 2020 Not working Okay, I know why, I kill him right away because Ped has 50 HP and he was dying right away, but thanks for the help Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now