KITT1995 Posted August 24, 2011 Share Posted August 24, 2011 I made this script funtion removeNeon () local neon = getAttachedElements (theVehicle) for index , attachedElement in ipairs ( neon ) do if getElementModel ( attachedElement ) == 3907 or getElementModel ( attachedElement ) == 3917 then destroyElement (attachedElement) end end end What I want is that when a car that have attached 3907 or 3917 element, when that car explode that element will be destroy too. If it is possible i want to that element destroy when a car will be unload (i mean the destroy command in admin panel). Link to comment
SDK Posted August 24, 2011 Share Posted August 24, 2011 When you create the objects, use setElementParent ( object, vehicle ), this will make the vehicle the parent of the objects. destroyElement will also destroy all children of the element you're destroying. Link to comment
KITT1995 Posted August 24, 2011 Author Share Posted August 24, 2011 When you create the objects, use setElementParent ( object, vehicle ), this will make the vehicle the parent of the objects. destroyElement will also destroy all children of the element you're destroying. It doesn't work with setElementParent. It only destroy the two elements of last vehicle that they were applied Link to comment
KITT1995 Posted August 25, 2011 Author Share Posted August 25, 2011 Can someone help me? Link to comment
KITT1995 Posted August 25, 2011 Author Share Posted August 25, 2011 this is the part of the script where I need help. I can't post the entire script cuz is too long funtion removeNeon () local neon = getAttachedElements (theVehicle) for index , attachedElement in ipairs ( neon ) do if getElementModel ( attachedElement ) == 3907 or getElementModel ( attachedElement ) == 3917 then destroyElement (attachedElement) end end end addEventHandler ( "onVehicleExplode", getRootElement(), removeNeon ) Link to comment
50p Posted August 25, 2011 Share Posted August 25, 2011 funtion removeNeon () local neon = getAttachedElements ( source ) for index , attachedElement in ipairs ( neon ) do if getElementModel ( attachedElement ) == 3907 or getElementModel ( attachedElement ) == 3917 then destroyElement ( attachedElement ) end end end addEventHandler ( "onVehicleExplode", getRootElement(), removeNeon ) Remember, onVehicle* events' source are the vehicles that the event occurred on. Link to comment
KITT1995 Posted August 25, 2011 Author Share Posted August 25, 2011 Thanks it works!! It works too when a vehicle gets destroy. Exactly what I wanted 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