Changing the server name according to which map is on?

Hey guys.

Essentially what I want to do is if map “x” is on the server name will be “Sandbox | Map X”

or

If map “y” is on then the server name will change to “Sandbox | Map Y” etc etc.

Is this possible? If so, how do I do it?

[lua]hook.Add(“InitPostEntity”, “SetServerName”, function()
local map = string.gsub(game.GetMap(), “.bsp”, “”)
RunConsoleCommand(“hostname”, "Sandbox | "…map)
end)[/lua]

Untested, should work.

Almost. Gsub will get mad at you for using “.” so replace “.bsp” with “%.bsp”

You don’t need to gsub it, game.GetMap does not return .bsp on the end.