Jump to content

return a table value


KITT1995

Recommended Posts

Posted

What you mean by "return table in chatbox"??

Outputting their types?

for index , attachedElement in ipairs ( getAttachedElements ( vehicle ) ) do 
outputChatBox ( getElementType ( attachedElement ) ) 
end 

Posted

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

Posted
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.

Posted
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?

Posted

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...

Posted
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 :roll:

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...