DRW Posted May 4, 2015 Share Posted May 4, 2015 Hello, I'm trying to make zombies to get killed when they get shot in the body. It actually works, but peds don't die properly, they appear as dead, but don't count as dead, even when you get a little far from them, they appear as walking without moving from the position where they died. Here's the function that I'm talking about. function Zheadhit ( ped,attacker, weapon, bodypart) if (getElementData (ped, "zombie") == true) then setElementHealth(ped,( getElementHealth(ped)-math.random(35))) setPedHeadless ( ped, false ) end end Link to comment
Walid Posted May 4, 2015 Share Posted May 4, 2015 Try this one function Zheadhit (attacker, weapon, bodypart) if (attacker and getElementType(attacker) == "player" and attacker ~= source) then if (getElementData (source, "zombie") == true) then local health = getElementHealth(source) setElementHealth(source,tonumber(health) - 25) setPedHeadless (source, false ) end end end addEventHandler ( "onClientPedDamage", getRootElement(), Zheadhit ) Link to comment
DRW Posted May 4, 2015 Author Share Posted May 4, 2015 Try this one function Zheadhit (attacker, weapon, bodypart) if (attacker and getElementType(attacker) == "player" and attacker ~= source) then if (getElementData (source, "zombie") == true) then local health = getElementHealth(source) setElementHealth(source,tonumber(health) - 25) setPedHeadless (source, false ) end end end addEventHandler ( "onClientPedDamage", getRootElement(), Zheadhit ) Nothing Link to comment
Tomas Posted May 4, 2015 Share Posted May 4, 2015 Client: function Zheadhit (attacker, weapon, bodypart) if (attacker and getElementType(attacker) == "player" and attacker ~= source) then if (getElementData (source, "zombie") == true) then local health = getElementHealth(source) if health <= 30 then killPed(source, attacker) else setElementHealth(source,tonumber(health) - 25) end setPedHeadless (source, false ) end end end addEventHandler ( "onClientPedDamage", getRootElement(), Zheadhit ) function killPed ( ped, killer ) triggerServerEvent("killPed", resourceRoot, ped, killer) end Server-side: function killPed_f (ped , killer) killPed(ped, killer) end addEvent( "killPed", true ) addEventHandler( "killPed", resourceRoot, killPed_f ) 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