Jump to content

Can't destroy a ped with destroyElement


alefpereira

Recommended Posts

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.)

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...