Jump to content

[HELP] SPAWN


MaRcell

Recommended Posts

  • Moderators

First of all, check the syntax of spawnPlayer. (https://wiki.multitheftauto.com/wiki/SpawnPlayer)

Quote

player thePlayer, float x, float y, float z

You need x, y and z, not a table.

 

I don't know why you want to use table only for 1 spawn, but then:

x, y, z = spawnLocation[1][1], spawnLocation[1][2], spawnLocation[1][3]
-- Why?
-- spawnLocation   => its the table
--              [1]   => its the first row of the table
--                 [2] => its the second value in the first row (the Y coord)

 

And here is a Lua tutorial, you should read that, if you want to learn.

 

Link to comment
  • Moderators

I don't understand what you want, but I think select a random spawnpoint in every time.

If yes, here is an example:

local rows = #spawnLocation -- example, returns 2 if have 2 spawnpoints in the table
local randomRowIndex = math.random(1, rows) -- return a number between 1 and length of the table. (what can be 1 or 2, if have 2 spawnpoints in the table)
local x, y, z = spawnLocation[randomRowIndex][1], spawnLocation[randomRowIndex][2], spawnLocation[randomRowIndex][3] -- get values like in previous example

 

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