Jump to content

Tabela de cordenada


Recommended Posts

Boa Noite,

Precisava de uma ajuda. Tenho uma função que ela manda coodenadas aleatorios quando jogador vai respwanar so que como é aleario ele repete aquela linha, queria fazer com que ela faz com linha exemplo, 1,2,3,4,5 ai depois do 5 volta para o 1 

 

Tabela

client.Lua

spawnPositionslv = {
    {2926,681,1000},
    {1876,633,1000},
    {1193,1125,1000},
    {1927,2028,1000},
    {2682,2299,1000},
    {1887,2654,1000},
    {918,2491,1000}
}
local lvs = math.random(#spawnPositionslv)
local x,y,z = spawnPositionslv[lvs][1],spawnPositionslv[lvs][2],spawnPositionslv[lvs][3]
spawnPlayer (player, x,y,z+0.5, math.random(0,360), 0, 0, 0)

 

Link to comment
  • Other Languages Moderators
local spawns = {
    {2926, 681, 1000},
    {1876, 633, 1000},
    {1193, 1125, 1000},
    {1927, 2028, 1000},
    {2682, 2299, 1000},
    {1887, 2654, 1000},
    {918, 2491, 1000}
}

local current = 0

function spawn(p)
    current = math.min(current + 1, #spawns)

    local x, y, z = spawns[current][1], spawns[current][2], spawns[current][3]
    
    fadeCamera(p, true)
    spawnPlayer(p, x, y, z, 360, 0, 0, 0)

    if current == #spawns then
        current = 0
    end
end

addEventHandler('onPlayerWasted', root,
    function()
        setTimer(spawn, 2000, 1, source)
    end
)

 

Link to comment
  • Other Languages Moderators
local spawns = {
    {2926, 681, 1000},
    {1876, 633, 1000},
    {1193, 1125, 1000},
    {1927, 2028, 1000},
    {2682, 2299, 1000},
    {1887, 2654, 1000},
    {918, 2491, 1000}
}

local current = 0

function spawn(p)
    if (current < #spawns) then
        current = current + 1
    else
        current = 1
    end
    local x, y, z = spawns[current][1], spawns[current][2], spawns[current][3]
    fadeCamera (p, true)
    spawnPlayer (p, x, y, z)
end

addEventHandler ("onPlayerWasted", root, function()
    setTimer(spawn, 2000, 1, source)
end)

 

Edited by Lord Henry
Correção de indentação.
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...