Ulysses Stuff > Suggestions
Loading a random map when the server starts up
Luk | twitch.tv/doctorluk:
Hello everyone :)
I'm having some - expected - problems with my TTT Server. As you all know GMod likes to crash once in a while and it's quite annoying if a map is being played many times because it's the server's default start map.
The start map is sometimes manually changed by me, but that is by far no permanent solution. I seek someone to create a script that randomly starts a map from the mappool on server start.
I've tried some LUA and made some progress but I'm not sure where to start and I'm also not sure whether there is a hook for the first server start.
Would be awesome if someone could help out :)
JamminR:
I'm 98% sure you wouldn't be able to do this strictly in lua.
I was about to say not at all, then my mind started thinking 'well, perhaps a startup batch file could read from a gmod\data\<somefile> that contains a map randomly selected on startup for NEXT time', but, unless you wanted the server to start up, load command line/config file map, then restart loading a random map, you'd HAVE to have the command line outside of lua loading whatever randomly selected map.
So, 2 options I see.
100% outside lua.
Have server start non-lua startup script randomly pick from map in a list.
Using GLua and outside.
Server starts, picks random, writes it to a \data\ file for next startup.
Next server start, command line reads the map from that \data\ file.
Tomzen:
--- Quote from: JamminR on March 05, 2015, 06:28:23 PM ---I'm 98% sure you wouldn't be able to do this strictly in lua.
I was about to say not at all, then my mind started thinking 'well, perhaps a startup batch file could read from a gmod\data\<somefile> that contains a map randomly selected on startup for NEXT time', but, unless you wanted the server to start up, load command line/config file map, then restart loading a random map, you'd HAVE to have the command line outside of lua loading whatever randomly selected map.
So, 2 options I see.
100% outside lua.
Have server start non-lua startup script randomly pick from map in a list.
Using GLua and outside.
Server starts, picks random, writes it to a \data\ file for next startup.
Next server start, command line reads the map from that \data\ file.
--- End quote ---
Could you not use an array and then get a random value from the array and force the map to it? or even read the maps/ directory and pick a map random from the names (this would cause problems unless the maps are named like: (e.g) gm_flatgrass)
Aaron113:
I worked on a game mode a while ago where if the server crashed, it would go back to the last map it was on. This is entirely possible through Lua and data files.
Timmy:
--- Quote from: Aaron113 on May 07, 2015, 03:52:53 PM ---I worked on a game mode a while ago where if the server crashed, it would go back to the last map it was on. This is entirely possible through Lua and data files.
--- End quote ---
Would such system load the server on a default map, check if it crashed, then load the map it was originally on?
Edit: I'm asking cause I think maps are loaded before Lua is. You wouldn't be able to manipulate this without loading the server twice. Correct me if I'm wrong though. :)
Navigation
[0] Message Index
[#] Next page
Go to full version