Padul Posted March 3, 2017 Share Posted March 3, 2017 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 Citizen Posted March 4, 2017 Moderators Share Posted March 4, 2017 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
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