• Get the maps of mapcycle.txt
    9 replies, posted
Hi, Is there a way to get every maps of the mapcycle.txt ? I know how to choose a random one from a table
    local maps = util.getValidMaps()     local nxmap = table.Random(maps) After doing that, what's the command to change the map ? I only found game.LoadNextMap()
Yeah but I'm getting an error What I'm I doing wrong ?
oh crap sorry i thought it was already in gmod
I think it's more likely that you simply don't have a mapcycle.txt file present on your server. It shouldn't be possible for that error to happen otherwise.
Ok i managed to make it work This wasn't working for no reason, the file was in the cfg folder local maps = file.Read( "mapcycle.txt", "cfg" ) But this is working when I put the file into the Data folder : local maps = file.Read( "mapcycle.txt", "DATA" )
Actually, there's a very good reason why that didn't work. That second argument is a special identifier that only has meaning to c++ classes implementing Valve's IFileSystem interface. It has no relation to the folder layout on disk. Each identifier represents a collection of paths to use in the file operation. "GAME" will look through all mounted content, while "MOD" will only look in the current mod folder (garrysmod, in this case). "DATA" will only look in the data folder, and it only exists to make it easier to sandbox file write operations from Lua. There are other identifiers, but you really only need to worry about the ones I mentioned. You can read the mapcycle file in the cfg folder like this: file.Read("cfg/mapcycle.txt", "MOD")
Sorry, you need to Log In to post a reply to this thread.