Jump to content

SetVihicleColor


SkiZo

Recommended Posts

Hello everyone .. i need some help .. 
car1 = createVehicle ( 451, 1612, 1831, 10.2, 0, 0, 0 ) 
car2 = createVehicle ( 451, 1618, 1831, 10.2, 0, 0, 0 ) 
car3 = createVehicle ( 451, 1625, 1831, 10.2, 0, 0, 0 ) 
i wonna set those cars to red color .. 
i know 

setVehicleColor( car1, 255, 0, 0 )
setVehicleColor( car2, 255, 0, 0 )
setVehicleColor( car1, 255, 0, 0 )

there is any other trick to do that ?? i mean 


setVehicleColor( [car1 and car2 and car3],255,0,0)  ???? 


#Just a question because i'm creating about 140 Red Car :'(  

 

Or useing table ?? ( I don't know how ) 
 

Link to comment

Eh, might be something like this


VehicleTables = {

veh1 =  createVehicle ( 451, 1625, 1831, 10.2, 0, 0, 0 ),
veh2 =  createVehicle ( 451, 1625, 1831, 10.2, 0, 0, 0 ),
veh3 =  createVehicle ( 451, 1625, 1831, 10.2, 0, 0, 0 ),
veh4 =  createVehicle ( 451, 1625, 1831, 10.2, 0, 0, 0 )

}


function setColors()
for k, v in pairs(VehicleTables) do
setVehicleColor( v, 255, 0, 0 )

end

 

Link to comment
vehicles = {}
-- Create 140 vehicles and set the color to red
for i=1, 140 do
  local x = 1625+((i-1)*5) -- Create 5 point space of each vehicle
  local veh = createVehicle(451, x, 1831, 10.2, 0, 0, 0)
  setVehicleColor(veh, 255, 0, 0)
  table.insert(vehicles, veh)
end

-- Or if you want a separated function
function setVehColor()
  for _, veh in pairs(vehicles) do
    setVehicleColor(veh, 255, 0, 0)
  end
end

 

Edited by idarrr
Typo
  • Like 1
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...