KITT1995 Posted August 23, 2011 Share Posted August 23, 2011 How i can return a table value in chatbox or console? I wanna get all attached elements that are attached to a car with getAttachedElements Link to comment
JR10 Posted August 23, 2011 Share Posted August 23, 2011 What you mean by "return table in chatbox"?? Outputting their types? for index , attachedElement in ipairs ( getAttachedElements ( vehicle ) ) do outputChatBox ( getElementType ( attachedElement ) ) end Link to comment
KITT1995 Posted August 23, 2011 Author Share Posted August 23, 2011 This is the code i wrote function destroyNeon ( thePlayer, commandName ) if ( thePlayer ) then local neon = getAttachedElements (veh) if neon == tablevalue? then destroyElement (mine) destroyElement (mine1) end end end What i wanna to do is that when a vehicle have mine and mine1 attached then those two elements will be destroyed. Help me plaease Link to comment
JR10 Posted August 23, 2011 Share Posted August 23, 2011 function destroyNeon ( thePlayer, commandName ) if ( thePlayer ) then local neon = getAttachedElements (veh) for index , attachedElement in ipairs ( neon ) do if getElementModel ( attachedElement ) == mineModel then destroyElement (attachedElement) end end end end Replace mineModel with mine's model. Link to comment
KITT1995 Posted August 23, 2011 Author Share Posted August 23, 2011 function destroyNeon ( thePlayer, commandName ) if ( thePlayer ) then local neon = getAttachedElements (veh) for index , attachedElement in ipairs ( neon ) do if getElementModel ( attachedElement ) == mineModel then destroyElement (attachedElement) end end end end Replace mineModel with mine's model. Thanks it works!!! However if there are multiple elements attached to the car with differents model ID, what i need to put in mineModel? Link to comment
E-mail Posted August 23, 2011 Share Posted August 23, 2011 ( attachedElement ) == mineModel Link to comment
JR10 Posted August 23, 2011 Share Posted August 23, 2011 You can add more checks if the model == Example: function destroyNeon ( thePlayer, commandName ) if ( thePlayer ) then local neon = getAttachedElements (veh) for index , attachedElement in ipairs ( neon ) do if getElementModel ( attachedElement ) == mineModel or getElementModel ( attachedElement ) == mineModel or getElementModel ( attachedElement ) == mineModel then destroyElement (attachedElement) end end end end Etc... Link to comment
KITT1995 Posted August 23, 2011 Author Share Posted August 23, 2011 You can add more checks if the model ==Example: function destroyNeon ( thePlayer, commandName ) if ( thePlayer ) then local neon = getAttachedElements (veh) for index , attachedElement in ipairs ( neon ) do if getElementModel ( attachedElement ) == mineModel or getElementModel ( attachedElement ) == mineModel or getElementModel ( attachedElement ) == mineModel then destroyElement (attachedElement) end end end end Etc... Ok thanks again i have forgot the 'or' thing 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