KITT1995 Posted August 23, 2011 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
JR10 Posted August 23, 2011 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 Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
KITT1995 Posted August 23, 2011 Author 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
JR10 Posted August 23, 2011 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. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
KITT1995 Posted August 23, 2011 Author 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?
JR10 Posted August 23, 2011 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... Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
KITT1995 Posted August 23, 2011 Author 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
JR10 Posted August 23, 2011 Posted August 23, 2011 You welcome. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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