KITT1995 Posted August 24, 2011 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).
bandi94 Posted August 24, 2011 Posted August 24, 2011 onVehicleExplode Ingame Name : |DGT|Puma DGT Clan Server 24/7 Owner/Scripter MultiGameMode in progress :
SDK Posted August 24, 2011 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. Learn Lua - Learn to script - GUI scripting Scripter tools - Find/fix errors yourself(!) Don't pm me for scripting help, keep it for the Scripting subforum!
KITT1995 Posted August 24, 2011 Author 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
SDK Posted August 25, 2011 Posted August 25, 2011 post the script Learn Lua - Learn to script - GUI scripting Scripter tools - Find/fix errors yourself(!) Don't pm me for scripting help, keep it for the Scripting subforum!
KITT1995 Posted August 25, 2011 Author 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 )
50p Posted August 25, 2011 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
KITT1995 Posted August 25, 2011 Author Posted August 25, 2011 Thanks it works!! It works too when a vehicle gets destroy. Exactly what I wanted
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