Author Topic: Map rotation  (Read 7235 times)

0 Members and 1 Guest are viewing this topic.

Offline Mass

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Map rotation
« on: December 15, 2006, 04:07:02 AM »
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

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Map rotation
« Reply #1 on: December 15, 2006, 06:59:18 PM »
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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Mass

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Map rotation
« Reply #2 on: December 16, 2006, 01:46:41 AM »
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

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Map rotation
« Reply #3 on: December 16, 2006, 09:30:45 AM »
Code: [Select]
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 )

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.
Experiencing God's grace one day at a time.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Map rotation
« Reply #4 on: December 27, 2006, 10:10:25 AM »
So how'd that script work for you Mass?
Experiencing God's grace one day at a time.

Offline ?The Merky Shadow?

  • Newbie
  • *
  • Posts: 1
  • Karma: -1
Re: Map rotation
« Reply #5 on: February 28, 2015, 12:29:03 PM »
Old thread...I know. I created a script you can find it here

http://facepunch.com/showthread.php?t=978871