Skip to content

Commit

Permalink
ADDED: Deathmatch Warmup Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nickj609 committed Sep 25, 2024
1 parent 787f7d8 commit 8d598a8
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 65 deletions.
3 changes: 2 additions & 1 deletion GameModeManager/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public class WarmupSettings
public List<ModeEntry> List { get; set; } = new List<ModeEntry>()
{
new ModeEntry() { Name = "Deathmatch", Config = $"warmup/dm.cfg", MapGroups = new List<string>() },
new ModeEntry() { Name = "Knives Only", Config = $"warmup/knives_only.cfg", MapGroups = new List<string>()}
new ModeEntry() { Name = "Knives Only", Config = $"warmup/knives_only.cfg", MapGroups = new List<string>()},
new ModeEntry() { Name = "Scoutz Only", Config = $"warmup/scoutz_only.cfg", MapGroups = new List<string>()}
};
}
public class RotationSettings
Expand Down
64 changes: 45 additions & 19 deletions GameModeManager/CrossCutting/ServerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,26 @@ public void OnConfigParsed(Config config)
// Define reusable method to change map
public void ChangeMap(Map nextMap)
{
// Disable warmup scheduler
if(_gameRules.WarmupRunning)
{
// End warmup
Server.ExecuteCommand($"mp_warmup_end");

// Delay freeze
new Timer(1.5f, () =>
{
Server.ExecuteCommand("bot_kick");
FreezePlayers();
});
}
else
{
// Kick bots and freeze all players
Server.ExecuteCommand("bot_kick");
FreezePlayers();
}

// Disable warmup scheduler
if (_config.Warmup.PerMap)
{
_pluginState.WarmupScheduled = false;
Expand Down Expand Up @@ -68,16 +87,31 @@ public void ChangeMap(Map nextMap)
// Define reusable method to change map
public void ChangeMap(Map nextMap, int delay)
{
if(_gameRules.WarmupRunning)
{
// End warmup
Server.ExecuteCommand($"mp_warmup_end");

// Delay freeze
new Timer(1.3f, () =>
{
Server.ExecuteCommand("bot_kick");
FreezePlayers();
});
}
else
{
// Kick bots and freeze all players
Server.ExecuteCommand("bot_kick");
FreezePlayers();
}

// Disable warmup scheduler
if (_config.Warmup.PerMap)
{
_pluginState.WarmupScheduled = false;
}

// Kick bots and freeze all players
Server.ExecuteCommand("bot_kick");
FreezePlayers();

// Display Countdown
CountdownTimer timer = new CountdownTimer(delay, () =>
{
Expand All @@ -95,6 +129,7 @@ public void ChangeMap(Map nextMap, int delay)
Server.ExecuteCommand($"ds_workshop_changelevel \"{nextMap.Name}\"");
}
}, "Map changing in ");

}

// Define reusable method to change mode
Expand All @@ -117,21 +152,12 @@ public void ChangeMode(Mode mode)
nextMap = mode.DefaultMap;
}

if(_gameRules.WarmupRunning)
{
Server.ExecuteCommand($"mp_warmup_end");
// Change to next map
ChangeMap(nextMap);

// Set current mode
_pluginState.CurrentMode = mode;

new Timer(1.0f, () =>
{
// Change to next map
ChangeMap(nextMap);
});
}
else
{
// Change to next map
ChangeMap(nextMap);
}
}

// Define method to trigger mode and map rotations
Expand Down
2 changes: 1 addition & 1 deletion GameModeManager/Features/ModeCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void OnGameModeCommand(CCSPlayerController? player, CommandInfo command)
{
if (player == null)
{
Mode? _mode = _pluginState.Modes.FirstOrDefault(m => m.Name.Equals(command.ArgByIndex(1), StringComparison.OrdinalIgnoreCase) || m.Config.Contains(command.ArgByIndex(1), StringComparison.OrdinalIgnoreCase));
Mode? _mode = _pluginState.Modes.FirstOrDefault(m => m.Name.Equals($"{command.ArgByIndex(1)}", StringComparison.OrdinalIgnoreCase) || m.Config.Equals($"{command.ArgByIndex(1)}.cfg", StringComparison.OrdinalIgnoreCase));

if(_mode != null && _pluginState.CurrentMode != _mode)
{
Expand Down
2 changes: 2 additions & 0 deletions GameModeManager/Timers/CountdownTimer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Included libraries
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Menu;
using GameModeManager.CrossCutting;
using Timer = CounterStrikeSharp.API.Modules.Timers.Timer;
using TimerFlags = CounterStrikeSharp.API.Modules.Timers.TimerFlags;
Expand Down Expand Up @@ -34,6 +35,7 @@ private void DisplayCountdown(string message)
{
foreach (CCSPlayerController player in Extensions.ValidPlayers(false))
{
MenuManager.GetActiveMenus().Clear();
player.PrintToCenterAlert(message + " " + interval.ToString() + "...");
}

Expand Down
56 changes: 56 additions & 0 deletions GameModeManager/lib/csgo/cfg/warmup/dm.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Set game mode
game_type 1
game_mode 2

// Load game mode
exec gamemode_deathmatch.cfg

// Unload plugins
exec unload_plugins.cfg

// Load custom plugins
css_plugins load "plugins/disabled/CS2-Remove-Map-Weapons/CS2-Remove-Map-Weapons.dll"

// Enable sv cheats
sv_cheats 1

// Load game mode settings
exec settings/enable_alltalk.cfg
exec settings/disable_drop_weapons.cfg

// Round convars
mp_friendlyfire 0
mp_forcecamera 0
mp_solid_teammates 0
mp_teammates_are_enemies 1
mp_free_armor 2
bot_randombuy true
mp_buy_anywhere 1
mp_buy_during_immunity 1
mp_randomspawn 1
mp_randomspawn_dist 0
mp_randomspawn_los 1
mp_respawn_immunitytime 3

// Hide money
mp_playercashawards 1
mp_teamcashawards 1

// Add bots
exec settings/enable_bots.cfg
exec custom_bots.cfg

// Load custom settings
exec custom_deathmatch.cfg

// Disable sv cheats
sv_cheats 0

// Warmup settings
mp_warmuptime 60
mp_warmuptime_all_players_connected 60
mp_warmup_online_enabled 1
mp_warmup_start

// Logging
echo "[Warmup Mode]: Knives only executed."
38 changes: 0 additions & 38 deletions GameModeManager/lib/csgo/cfg/warmup/he_only.cfg

This file was deleted.

4 changes: 2 additions & 2 deletions GameModeManager/lib/csgo/cfg/warmup/knives_only.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ mp_round_restart_delay 3
mp_team_intro_time 0

// Warmup settings
mp_warmuptime 120
mp_warmuptime_all_players_connected 120
mp_warmuptime 60
mp_warmuptime_all_players_connected 60
mp_warmup_online_enabled 1
mp_warmup_start

Expand Down
8 changes: 4 additions & 4 deletions GameModeManager/lib/csgo/cfg/warmup/scoutz_only.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ mp_t_default_secondary ""
mp_ct_default_secondary ""
mp_t_default_melee weapon_knife
mp_ct_default_melee weapon_knife
mp_t_default_primary ""
mp_ct_default_primary ""
mp_t_default_primary weapon_ssg08
mp_ct_default_primary weapon_ssg08
mp_free_armor 1
mp_freezetime 10
mp_give_player_c4 0
Expand All @@ -29,8 +29,8 @@ mp_round_restart_delay 3
mp_team_intro_time 0

// Warmup settings
mp_warmuptime 120
mp_warmuptime_all_players_connected 120
mp_warmuptime 60
mp_warmuptime_all_players_connected 60
mp_warmup_online_enabled 1
mp_warmup_start

Expand Down

0 comments on commit 8d598a8

Please sign in to comment.