General > Off-Topic

Map rotation

(1/2) > >>

Mass:
Can anyone help me with this?  How can you set up a map rotation?  I want the server to automatically change maps every 60 mins but there is no map rotation that I can find anywhere

Please help

JamminR:
Mass,
 Garry's mod 10 I take it?
There were a few GM9 releases that would do this. I've not searched facepunch forums lately, but know they existed.
Do you know Lua? Perhaps you could write one in Lua.

Mass:
It is Gmod10 yes but I have absolutely no idea how to use lua to make anything.  I just wasn't sure if I had missed something when creating the server but if it doesn't have this option as standard, I'll just have to wait until someone creates something

Thanks for your reply

Megiddo:

--- Code: ---local maptime = 3600
local warning = 3540
local maps = {
"gm_construct",
"gm_910",
}

local warned
local checkTime()
local players = player.GetAll()

if not warned and CurTime() > warning then
for _, player in ipairs( players ) do
player:PrintMessage( HUD_PRINTTALK, "WARNING: Map will be changed shortly!" )
end
warned = true
end

if CurTime() > maptime then
local nextmap
if table.HasValue( game.GetMap() ) then
for i, map in ipairs( maps ) do
if map == game.GetMap() then
nextmap = maps[ math.fmod( i + 1, #maps ) ]
end
end
else
nextmap = maps[ math.random( #maps ) ]
end
game.ConsoleCommand( "changelevel " .. nextmap .. "\n" )
end
end
timer.Create( "MapRotation", 60, 0, checkTime )
--- End code ---

Just a quick untested writeup. Let me know if it doesn't work. You'll need to add whatever maps you want on the rotation into that table, and they'll go in sequence.

Megiddo:
So how'd that script work for you Mass?

Navigation

[0] Message Index

[#] Next page

Go to full version