Changing between several hostnames

Anyone know how to do so the server name is changing between several names?.

Something like



local name = "whatever"
game.ConsoleCommand( "hostname " .. name .. "
" )


And then just have a timer which goes through a table of possible hostnames and runs that command on it.



local M = {}
M[1] = "Test 1"
M[2] = "Test 2"
M[3] = "Test 3"
M[4] = "Test 4"
M[5] = "Test 5"

game.ConsoleCommand("hostname Server name on startup.
")
timer.Create("Title",600,0,function()
	local message = M[math.random(1,#M)]
	game.ConsoleCommand("hostname Server name with a custom message: "..message.."
")
end)


That way, if you’re unlucky, you could have the same hostname for several cycles. Of course the OP didn’t say that was a problem so sure, it’ll work but:



local names = {
	"Name 1",
	"Name 2",
	"Name 3",
	"Name 4",
}

local i = 0
timer.Create( "Hostname", 600, 0, function()
	i = i % #names + 1
	game.ConsoleCommand( "hostname " .. names[ i ] .. "
" )
end )


Only issue left is that hostnames are cached.