Hey guys I'm newbie in lua scripting. I have the following problem:
I have a function that creates a dead body if a ped receive damage, this function works perfectly creating a dead ped with the exception of destroyElement(source) that does not destroy the live body.
on each damage that the ped receive a dead body is created, and the live body isn't destroyed.
this generates a duplicated body (the living and the dead)
I wanted only the dead ped to show up.
server-side:
function createDeadPed()
local x,y,z = getElementPosition(source)
local skin = getElementModel(source)
local ped = createPed(skin,x,y,z)
killPed(ped) --creates a dead body
destroyElement(source) --BUG!! => this function isn't destroying the live body
end
addEvent("createDeadPed",true)
addEventHandler ( "createDeadPed",getRootElement(),createDeadPed)
client-side:
function pedDamage(attacker,weapon)
if attacker == getLocalPlayer() then
if getElementData(source,"myped") then
if weapon and weapon > 1 then
triggerServerEvent("createDeadPed",source)
end
end
end
end
addEventHandler ( "onClientPedDamage",getRootElement(),pedDamage)
OBS: My source is the ped that receives damage.
(I hope my explanation wasn't confused, thanks.)