1. What is the simplest way to get the current gamemode? I know engine.GetGamemodes() gets a list of installed gamemodes, but it doesn't return anything about which is the current one.
2. Also, when using engine.GetGamemodes(), how does it order the list? Alphabetical by title?
Here's what I use:
[lua]
PInfo_IsTTT = false // Force true if gamemode is not the same name.
function PInfo_IsTTTActive()
if PInfo_IsTTT or gmod.GetGamemode().Name == "Trouble in Terrorist Town" then return true end
return false
end
[/lua]
So gmod.GetGamemode().Name will return the current gamemode?
[QUOTE=Chiz Dippler;42939406]So gmod.GetGamemode().Name will return the current gamemode?[/QUOTE]
It returns the display name, not the folder name or the name used to set the gamemode through console cmd.
Awesome. Thanks!
Btw, gmod.GetGamemode() returns a table and .Name is just one of its variable. Just PrintTable( gmod.GetGamemode() ) to see the list of available variables.
I am pretty sure you can get gamemode folder from "gamemode" convar on server.
So I just tried gmod.GetGamemode().Name and it returned a nil value. It was probably only because of the way I was using it.
However, I found a much more reliable global non-constant listed on the wiki, [URL="http://wiki.garrysmod.com/page/GlobalVariables"]GAMEMODE_NAME[/URL].
Sorry, you need to Log In to post a reply to this thread.