kevin433 Posted February 23, 2010 Share Posted February 23, 2010 Hi, I'm currently working on my Vehicle system. Now I want to spawn multiple cars at the same time, and that's working, but I want to set the Vehicle Color for each, and I'm using a for loop. How can I do this? That's how my code i currently looking: function createCar() local resultvehicle = executeSQLSelect("Vehicles","*") if(#resultvehicle == 0) then else for i = 1, 2 do createVehicle(resultvehicle[i].ModelID, resultvehicle[i].PosX,resultvehicle[i].PosY,resultvehicle[i].PosZ) end end end addCommandHandler("createcar", createCar) Link to comment
50p Posted February 23, 2010 Share Posted February 23, 2010 for i = 1, 2 do local tempVeh = createVehicle(resultvehicle[i].ModelID, resultvehicle[i].PosX,resultvehicle[i].PosY,resultvehicle[i].PosZ) setVehicleColor( tempVeh, 126, 126 ); end Link to comment
kevin433 Posted February 23, 2010 Author Share Posted February 23, 2010 Thanks 50p! BTW: Is the loop now re-defining "tempVeh" every time it runs through? Does it work this way? Link to comment
Jumba' Posted February 23, 2010 Share Posted February 23, 2010 Thanks 50p! BTW: Is the loop now re-defining "tempVeh" every time it runs through? Does it work this way? Yup, every time it goes through tempVeh will get the element data of the newly created vehicle. Link to comment
kevin433 Posted February 23, 2010 Author Share Posted February 23, 2010 My last question is now: If I do this in the loop, will it get "saved" for the specific vehicle? setElementData(tempVeh, ....... Link to comment
Jumba' Posted February 23, 2010 Share Posted February 23, 2010 My last question is now: If I do this in the loop, will it get "saved" for the specific vehicle? setElementData(tempVeh, ....... Yep 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