Jump to content

Help | Table & createVehicle()


novo

Recommended Posts

Posted

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.

Posted

Do you have any error regarding the vehicle creation?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 
  

Posted

And what is that error?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

At which argument?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

  
spawn = createVehicle ( element.model, element.posX, element.posY, element.posZ, element.rotX, element.rotY, element.rotZ ) 
  

Line 30

Posted

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.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 
  

Posted

Instead of:

outputChatBox("BEFOREFOR") 

Add:

outputChatBox ( #spawnPoints ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

That means spawnPoints table is empty, that's why it doesn't output "FOR".

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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) 
  

Posted

That's what it seems to be happening.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

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