If gamemode = then

Hey there,

I am currently using file.exist to execute my servers configuration which works fine, But I would like to set it specified to the game mode,
How could I do this?

Something like:

local Gamemode = string.find(GetConVarString(“sv_gamemode”)),“Gamemode_Name_To_Find”)) ?

so If thats correct…

[lua]
if local Gamemode = string.find(GetConVarString(“sv_gamemode”)),“gamemode”)) then

	RunConsoleCommand("hostname", "servername");
	RunConsoleCommand("sv_password", "");
	RunConsoleCommand("sv_downloadurl", "");

– and so on…
[/lua]

Should work?

Ill take a look now.

[editline]03:45PM[/editline]

Didn’t work, I’ve got an Unexpected symbol near local, jsut for a bit more information this is what I’ve got.

[lua]

if local Gamemode = string.find(GetConVarString("sv_defaultgamemode")),"gamemode1")) then
	RunConsoleCommand("hostname", "[Tag] Servername");
	RunConsoleCommand("sv_password", "");
	RunConsoleCommand("sv_downloadurl", "");

elseif local Gamemode = string.find(GetConVarString("sv_defaultgamemode")),"gamemode2")) then
	RunConsoleCommand("hostname", "[Tag] Servername");
	RunConsoleCommand("sv_password", "");
	RunConsoleCommand("sv_downloadurl", "")
else
	RunConsoleCommand("hostname", "[Tag] Servername");
	RunConsoleCommand("sv_password", "");
	RunConsoleCommand("sv_downloadurl", "")

end
[/lua]

[lua]
if( string.match(GetConVarString(“sv_defaultgamemode”), “gamemode_name”) ) then
RunConsoleCommand(“hostname”, “[TAG] servername”)
elseif( string.match(GetConVarString(“sv_defaultgamemode”), “gamemode2_name”) ) then
RunConsoleCommand(“hostname”, “[TAG] servername”)
end
[/lua]

It works!

Thank you :smiley:

[editline]05:57PM[/editline]

Oh yes, just do you know what its for I’m making all my servers run from 1 directory, Just having all the content in their specified gamemode folders, It works anyway And all the Resource/Dlfiles have been added into their specified gamemodes :slight_smile:

[lua] if gmod.GetGamemode().Folder == “sandbox” then[/lua]

Is what I prefer.

GAMEMODE.Name

My personal preference.

Those 2 would work aswell, But the one I was given has more possibilities than the ones you and the person above supplied, thank you anyway :slight_smile:

Which is also the proper way to do it.

if GAMEMODE.FolderName == “sandbox” then

That’s the most compatible and appropriate method you should use.