Jump to content

|Question| How to create a Gamemode


Kaos

Recommended Posts

Posted

Hello Guys i´ve got some questions about how to create a gamemode, i just dunno how can í create 3 spawns like on a play server but without freeroam resource and different locations. Can you help me with examples?

Posted
local positions = { 
   -- {x,y,z[,rot]}, 
} 
  
function randomSpawn(player) 
    local postab = positions[math.random(1,#positions)] 
    local x,y,z,rot = postab[1],postab[2],postab[3],postab[4] or 0 
    spawnPlayer(player,x,y,z,rot) 
end 
  

call random spawn from join, wasted events

Posted
local positions = { 
   -- {x,y,z[,rot]}, 
} 
  
function randomSpawn(player) 
    local postab = positions[math.random(1,#positions)] 
    local x,y,z,rot = postab[1],postab[2],postab[3],postab[4] or 0 
    spawnPlayer(player,x,y,z,rot) 
end 
  

call random spawn from join, wasted events

Thank you.

Posted
...

You could also use:

unpack (table) 

Instead of:

table[1], table[2] --... 

local positions = { 
   -- {x,y,z[,rot]}, 
} 
  
function randomSpawn(player) 
    local postab = positions[math.random(1,#positions)] 
    local x,y,z,rot = unpack (postab, 1, 3) 
    local rot = postab[4] or 0 
    spawnPlayer(player,x,y,z,rot) 
end 
  

Posted
...
local positions = { 
   -- {x,y,z[,rot]}, 
} 
  
function randomSpawn(player) 
    local postab = positions[math.random(1,#positions)] 
    local x,y,z,rot = unpack (postab, 1, 3) 
    local rot = postab[4] or 0 
    spawnPlayer(player,x,y,z,rot) 
end 
  

You right ;) i hope both variants will be useful for topic author :roll:

Posted

The unpack version is slower than the first solution.

So better use the first solution, not the one with unpack.

Don't forget to use fadeCamera and setCameraTarget.

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