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? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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
Castillo Posted January 7, 2013 Posted January 7, 2013 And what is that error? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
novo Posted January 7, 2013 Author Posted January 7, 2013 Huh, I'm getting Bad Argument @ createVehicle()
Castillo Posted January 7, 2013 Posted January 7, 2013 At which argument? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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 ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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 ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted January 7, 2013 Posted January 7, 2013 That means spawnPoints table is empty, that's why it doesn't output "FOR". San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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)
Castillo Posted January 7, 2013 Posted January 7, 2013 That's what it seems to be happening. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
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