Jump to content

Problem with string


Recommended Posts

Better way is to use tables instead:

local vehs = { 
    createVehicle( ... ), 
    createVehicle( ... ) 
}; 
  
for _, veh in pairs( vehs ) do 
    local x,y,z = getElementPosition( veh ); 
    outputChatBox( x .. ", " .. y .. ", " .. z ); 
end 

If you really want to get variables by their names you can use global table (_G) but I do not recommend it because in some cases this will return nil:

local veh1 = createVehicle( ... ); 
  
outputChatBox( "Vehicle name: " .. getVehicleName( _G["veh1"] ) ) 

Link to comment

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