Jump to content

Help | Table & createVehicle()


novo

Recommended Posts

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.

Link to comment

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 
  

Link to comment

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 ) 

Link to comment

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 
  

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