Jump to content

Spawn points


[MTA]Weed

Recommended Posts

Posted
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

 

430x73_FFFFFF_FF9900_000000_000000.png

Posted

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

 

Lua Scripter

?ucet=miki_cz

Owner of mshost.cz MTA portal.

Posted

Adding spawn points will be through adding more spawns in the main table. Could you present the way you add more spawns into the table so we can know if you doing it right?

 

●●●

Rage Gaming Society

Coming Soon

●●●

Posted
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 )
 

 

430x73_FFFFFF_FF9900_000000_000000.png

Posted
local spawns = { 
{ -2030.1610107422, 172.25221252441, 28.8359375, 90.0 },
{ 423.2495, 453.2564, 564.6321, 120.6928 }
}



local rnd = math.random( #spawns )

spawnPlayer( player,  spawns[rnd][1], spawns[rnd][2], spawns[rnd][3], spawns[rnd][4])

 

  • Like 1
  • Thanks 1

76561198095270230.png

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