Choose random map on server startup GMOD

garrys-modhosting

I run a dedicated TTT server for friends, and I have the server set to restart every day to get addon updates. Is there a way to make it start on random map?

Best Answer

If you're using a linux host and have basename available you could adapt this launch.sh I wrote to do this for my server.

#!/bin/bash
RANDOM_MAP=$(find gmod/garrysmod/maps -type f -name "*.bsp" | shuf -n 1 | xargs basename | cut -d. -f1)
./gmod/srcds_run +map $RANDOM_MAP

You'll just need to replace the path with your own maps directory path.