Jump to content

destroyElement problem


Padul

Recommended Posts

serverside


	local fb={}

	if policeSigState == 0 then
		setElementData ( playerOccupiedRadiolka ,"radiolka:signalsstate",1)
		fb.wuwuni = createObject ( 1845, x , y , z , xr , yr, zr )
		attachElements ( fb.wuwuni , playerOccupiedRadiolka, -0.5 , -0.05 , 0.9 )
	elseif policeSigState == 1 then
		setElementData ( playerOccupiedRadiolka ,"radiolka:signalsstate",0)
		destroyElement ( fb.wuwuni )
	end

	WARNING: Bad argument @ 'destroyElement' [Expected element at argument 1, got nill]
	

can someone explain me that and maybe help :)?

the problem is that i have more than one car that will have attached object wuwuni, it appears that if i create object on two vehicles then its possible to me to destroy element on the first vehicle

Link to comment
  • Moderators

Try this (using an element data so it's the vehicle who is in charge to keep a reference to wuwuni instead of a server variable):

if policeSigState == 0 then
    local wuwuni = createObject ( 1845, x , y , z , xr , yr, zr )
    setElementData ( playerOccupiedRadiolka ,"radiolka:signalsstate",1)
    setElementData ( playerOccupiedRadiolka ,"radiolka:signalsobject", wuwuni )
    attachElements ( wuwuni , playerOccupiedRadiolka, -0.5 , -0.05 , 0.9 )
elseif policeSigState == 1 then
    setElementData ( playerOccupiedRadiolka ,"radiolka:signalsstate",0)
    local wuwni = getElementData ( playerOccupiedRadiolka , "radiolka:signalsobject" )
    if wuwni and isElement( wuwni ) then
        destroyElement ( wuwuni )
    end
end

if policeSigState == 0 then
	local wuwuni = createObject ( 1845, x , y , z , xr , yr, zr )
	setElementData ( playerOccupiedRadiolka ,"radiolka:signalsstate",1)
	setElementData ( playerOccupiedRadiolka ,"radiolka:signalsobject", wuwuni )
	attachElements ( wuwuni , playerOccupiedRadiolka, -0.5 , -0.05 , 0.9 )
elseif policeSigState == 1 then
	setElementData ( playerOccupiedRadiolka ,"radiolka:signalsstate",0)
	local wuwni = getElementData ( playerOccupiedRadiolka , "radiolka:signalsobject" )
	if wuwni and isElement( wuwni ) then
		destroyElement ( wuwuni )
	end
end

 

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