Jump to content

Spawn points


[MTA]Weed

Recommended Posts

function FreeroamRespawn(player)

    if not isElement(player) then return end

    local element = getElementParent(player)
    
    if getElementData(player, "state") ~= "Waiting" then return end

      repeat until spawnPlayer ( player, -711+math.random(1,5), 957+math.random(5,9), 12.4, 90, math.random(312), 0, 0) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
    showChat(player, true) 
    toggleAllControls(player, true, true, true)
end

the first works perfectly but has only 1 spawn locaion, but when i try adding more spawn points it dont work,my gamemode crashes what am i missing?

the code below i used to adding more spawn locations.

function spawn(player)

local spawns = { }

spawns[1] = { }

spawns[1].x = -2030.1610107422

spawns[1].y = 172.25221252441

spawns[1].z = 28.8359375

spawns[1].rot = 90.0

 

 spawns[2] = { }

spawns[2].x = 423.2495

spawns[2].y = 453.2564

spawns[2].z = 564.6321

spawns[2].rot = 120.6928



local rnd = math.random( #spawns )

spawnPlayer( player, spawns[rnd].x, spawns[rnd].y, spawns[rnd].z, spawns[rnd].rot )

end

 

Link to comment

That repeat loop makes no sense, you're not repeating anything and it will always pass the first time.. so It's like it's not even there.

I don't see anything wrong the the spawn function, so just use this instead:

function FreeroamRespawn(player)

    if not isElement(player) then return end

    local element = getElementParent(player)
    
    if getElementData(player, "state") ~= "Waiting" then return end

    spawn(player)
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
    showChat(player, true) 
    toggleAllControls(player, true, true, true)
end

 

Link to comment
local spawns = { }

spawns[1] = { }

spawns[1].x = -2030.1610107422

spawns[1].y = 172.25221252441

spawns[1].z = 28.8359375

spawns[1].rot = 90.0

 

 spawns[2] = { }

spawns[2].x = 423.2495

spawns[2].y = 453.2564

spawns[2].z = 564.6321

spawns[2].rot = 120.6928



local rnd = math.random( #spawns )

spawnPlayer( player, spawns[rnd].x, spawns[rnd].y, spawns[rnd].z, spawns[rnd].rot )
 

 

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