#RooTs Posted February 3, 2016 Author Share Posted February 3, 2016 And why did you post this code now?!Did you try the code I sent to you? added more function function detachNeon ( theVehicle ) local attachedElements = getAttachedElements ( theVehicle ) for i,v in pairs ( attachedElements ) do --detachElements ( v, theVehicle ) is this even needed? If yes then activate it destroyElement ( v ) end end addEvent( "detachNeon", true ) addEventHandler( "detachNeon", getRootElement(), detachNeon ) its function local playerInVehicle = {} local vehicleGotPlayer = {} function detachNeon ( theVehicle ) local attachedElements = getAttachedElements ( theVehicle ) for i,v in pairs ( attachedElements ) do --detachElements ( v, theVehicle ) is this even needed? If yes then activate it destroyElement ( v ) end end addEvent( "detachNeon", true ) addEventHandler( "detachNeon", getRootElement(), detachNeon ) addEventHandler ( "onVehicleEnter", root, function ( player, seat ) if seat == 0 then playerInVehicle[player] = source vehicleGotPlayer[source] = player addEventHandler ( "onPlayerQuit", player, removeNeonOnEvent ) addEventHandler ( "onPlayerVehicleExit", player, removeNeonOnEvent ) addEventHandler ( "onVehicleExplode", source, removeNeonOnEvent ) end end ) function removeNeonOnEvent ( vehicle ) local vehicle = vehicle or getElementType ( source ) == "vehicle" and source or playerInVehicle[source] local player = getElementType ( source ) == "player" and source or vehicleGotPlayer[vehicle] detachNeon ( vehicle ) playerInVehicle[player] = nil vehicleGotPlayer[vehicle] = nil setElementData ( player, "neon", 0 ) removeEventHandler ( "onPlayerQuit", player, removeNeonOnEvent ) removeEventHandler ( "onPlayerVehicleExit", player, removeNeonOnEvent ) removeEventHandler ( "onVehicleExplode", vehicle, removeNeonOnEvent ) end the problem still remains Link to comment
#RooTs Posted February 3, 2016 Author Share Posted February 3, 2016 (edited) this problem haunts me Edited February 3, 2016 by Guest Link to comment
Bonus Posted February 3, 2016 Share Posted February 3, 2016 Oh, didint see the video. The easiest way is to save the neon in an array with vehicle as index and use it in detachNeon. neonarray[vehicle] = { neon1, neon2 ... } And something I never tested: You can use setElementParent. Let the vehicle become the parent of the neonlights. If the vehicle gets destroyed the neonlights will get destroyed too. Link to comment
#RooTs Posted February 3, 2016 Author Share Posted February 3, 2016 @Bonus, look my MP Link to comment
#RooTs Posted February 3, 2016 Author Share Posted February 3, 2016 guys, my problem was not solved. I can send one part of my code by MP, so you can see how I did Link to comment
Bonus Posted February 3, 2016 Share Posted February 3, 2016 Did you even do what I told you? Link to comment
#RooTs Posted February 3, 2016 Author Share Posted February 3, 2016 Did you even do what I told you? yes I did but his example did not help me much, I could hardly understand him. I am already for days trying various ways, You can solve it for me? 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