novo Posted January 7, 2013 Posted January 7, 2013 Hello, I'm having troubles with adding a created vehicle to a table, here's my code; spawnPoints = {} spawn = nil spawn = createVehicle ( element.model, element.posX, element.posY, element.posZ, element.rotX, element.rotY, element.rotZ ) table.insert(spawnPoints, spawn) I'm using spawnPoints table for warping the player here; but it's not working, error at warpPlayerIntoVehicle. for i=1,#spawnPoints do spawnPlayer ( spawned, 0.0, 0.0, 5.0, 90.0, 0 ) spawnpoint = spawnPoints[i] warpPlayerIntoVehicle( spawned, spawnPoints[i]) end Thanks in advance.
Castillo Posted January 7, 2013 Posted January 7, 2013 Do you have any error regarding the vehicle creation?
novo Posted January 7, 2013 Author Posted January 7, 2013 No, I'm having error on warpPlayerIntoVehicle() PD: Full for loop; spawnPoints = {} for i, element in ipairs ( elements ) do if(element.type == "object") then createObject( element.model, element.posX, element.posY, element.posZ, element.rotX, element.rotY, element.rotZ ) elseif ( element.type == "vehicle" ) then createVehicle ( element.model, element.posX, element.posY, element.posZ, element.rotX, element.rotY, element.rotZ ) elseif ( element.type == "spawnpoint" ) then spawn = nil spawn = createVehicle ( element.model, element.posX, element.posY, element.posZ, element.rotX, element.rotY, element.rotZ ) table.insert(spawnPoints, spawn) end end
novo Posted January 7, 2013 Author Posted January 7, 2013 Huh, I'm getting Bad Argument @ createVehicle()
novo Posted January 7, 2013 Author Posted January 7, 2013 spawn = createVehicle ( element.model, element.posX, element.posY, element.posZ, element.rotX, element.rotY, element.rotZ ) Line 30
Castillo Posted January 7, 2013 Posted January 7, 2013 I said at which function argument, anyway, try this and see what the script outputs: outputChatBox ( tostring ( element.model ) ) outputChatBox ( tostring ( element.posX ) ) outputChatBox ( tostring ( element.posY ) ) outputChatBox ( tostring ( element.posZ ) ) outputChatBox ( tostring ( element.rotX ) ) outputChatBox ( tostring ( element.rotY ) ) outputChatBox ( tostring ( element.rotZ ) ) spawn = createVehicle ( element.model, element.posX, element.posY, element.posZ, element.rotX, element.rotY, element.rotZ )
novo Posted January 7, 2013 Author Posted January 7, 2013 I've solved it, my mistake. I had to add element.vehicle instead of element.model. Anyway, I've got spawnPlayer() problem now. I've this; but it doesn't output "FOR" outputChatBox("BEFOREFOR") for i=1,#spawnPoints do outputChatBox("FOR") spawnPlayer ( spawned, 0.0, 0.0, 5.0, 90.0, 0 ) warpPlayerIntoVehicle( spawned, spawnPoints[i]) fadeCamera (spawned, true) setCameraTarget (spawned, spawned) end
Castillo Posted January 7, 2013 Posted January 7, 2013 Instead of: outputChatBox("BEFOREFOR") Add: outputChatBox ( #spawnPoints )
Castillo Posted January 7, 2013 Posted January 7, 2013 That means spawnPoints table is empty, that's why it doesn't output "FOR".
novo Posted January 7, 2013 Author Posted January 7, 2013 So; isn't inserting the vehicle to the table or? spawn = nil spawn = createVehicle ( element.model, element.posX, element.posY, element.posZ, element.rotX, element.rotY, element.rotZ ) table.insert(spawnPoints, spawn)
Anderl Posted January 7, 2013 Posted January 7, 2013 createVehicle is most likely still returning false, so you're adding a boolean value to an array which basically means you're adding nothing.
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