Skip to content

Commit

Permalink
Adds support for a custom map in launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Lein committed May 8, 2024
1 parent 0838182 commit f18e96e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions CS2-server-launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics;
using System.IO;

namespace CS2DedicatedServer
namespace StringManipulation
{
class Program
{
Expand Down Expand Up @@ -89,7 +89,8 @@ public static bool SelectMap(string selectedgameName, string selectedgame_type,
Console.WriteLine("5) Nuke");
Console.WriteLine("6) Overpass");
Console.WriteLine("7) Vertigo");
Console.WriteLine("8) Exit");
Console.WriteLine("8) Custom map");
Console.WriteLine("9) Exit");
Console.Write("\r\nSelect an option: ");

switch (Console.ReadLine())
Expand Down Expand Up @@ -122,6 +123,16 @@ public static bool SelectMap(string selectedgameName, string selectedgame_type,
selectedMap = "de_Vertigo";
PreviewLaunch(selectedgameName, selectedMap, selectedgame_type, selectedgame_mode);
return true;
case "8":
Console.WriteLine("Please type in custom map (Name without file extension, ie. de_anubis, de_vertigo etc.");
selectedMap = Console.ReadLine();
if (string.IsNullOrEmpty(selectedMap))
{
Console.WriteLine("no map selected, exiting app");
Environment.Exit(0);
}
PreviewLaunch(selectedgameName, selectedMap, selectedgame_type, selectedgame_mode);
return true;
default:
return true;
}
Expand Down Expand Up @@ -172,7 +183,7 @@ private static void LaunchServer(string selectedGamemode, string selectedMap, st

string cs2ExePath = GetCs2ExePath();
Process.Start(@"netsh", "advfirewall firewall add rule name=\"CS2 Server port\" dir=in action=allow protocol=UDP localport=27015");
Process.Start(cs2ExePath, "-dedicated -usercon +game_type "+selectedgame_type+" +game_mode "+selectedgame_mode+" +map " +selectedMap);
Process.Start(@"C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\game\bin\win64\cs2.exe", "-dedicated -usercon +game_type "+selectedgame_type+" +game_mode "+selectedgame_mode+" +map " +selectedMap);
Environment.Exit(0);
}
}
Expand Down

0 comments on commit f18e96e

Please sign in to comment.