Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added config to automatically make joining players join the queue #112

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ When the plugin is first loaded it will create a `retakes_config.json` file in t
| IsDebugMode | Whether to enable debug output to the server console or not. | false | false | true |
| ShouldForceEvenTeamsWhenPlayerCountIsMultipleOf10 | Whether to force even teams when the active players is a multiple of 10 or not. (this means you will get 5v5 @ 10 players / 10v10 @ 20 players) | true | false | true |
| EnableFallbackBombsiteAnnouncement | Whether to enable the fallback bombsite announcement. | true | false | true |
| AddJoiningPlayersToQueue | Whether to add players to the queue when they join the game. | false | false | true |

## Commands
| Command | Arguments | Description | Permissions |
Expand Down
3 changes: 2 additions & 1 deletion RetakesPlugin/Modules/Configs/RetakesConfigData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class RetakesConfigData
{
public static int CurrentVersion = 8;
public static int CurrentVersion = 9;

public int Version { get; set; } = CurrentVersion;
public int MaxPlayers { get; set; } = 9;
Expand All @@ -19,4 +19,5 @@ public class RetakesConfigData
public bool IsDebugMode { get; set; } = false;
public bool ShouldForceEvenTeamsWhenPlayerCountIsMultipleOf10 { get; set; } = true;
public bool EnableFallbackBombsiteAnnouncement { get; set; } = true;
public bool AddJoiningPlayersToQueue { get; set; } = false;
}
4 changes: 4 additions & 0 deletions RetakesPlugin/Modules/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ mp_death_drop_gun 1
mp_death_drop_defuser 1
mp_death_drop_grenade 1
mp_warmuptime 15

// If AddJoiningPlayersToQueue is enabled, then the following commands are required:
// sv_human_autojoin_team 3
// mp_force_pick_time -1

echo [Retakes] Config loaded!
";
Expand Down
40 changes: 24 additions & 16 deletions RetakesPlugin/RetakesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace RetakesPlugin;
[MinimumApiVersion(201)]
public class RetakesPlugin : BasePlugin
{
private const string Version = "2.0.2";
private const string Version = "2.1.0";

#region Plugin info
public override string ModuleName => "Retakes Plugin";
Expand Down Expand Up @@ -505,21 +505,29 @@ public HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventIn
return HookResult.Continue;
}

// TODO: We can make use of sv_human_autojoin_team 3 to prevent needing to do this.
player.TeamNum = (int)CsTeam.Spectator;
player.ForceTeamTime = 3600.0f;

// Create a timer to do this as it would occasionally fire too early.
AddTimer(1.0f, () =>
{
if (!player.IsValid)
{
return;
}

player.ExecuteClientCommand("teammenu");
});

player.TeamNum = (int)CsTeam.Spectator;

if (_retakesConfig?.RetakesConfigData?.AddJoiningPlayersToQueue ?? false)
{
_gameManager?.QueueManager.PlayerJoinedTeam(player, CsTeam.Spectator, CsTeam.CounterTerrorist);
}
else
{
// Give the player time to choose a team.
player.ForceTeamTime = 3600.0f;

// Create a timer to do this as it would occasionally fire too early.
AddTimer(1.0f, () =>
{
if (!player.IsValid)
{
return;
}

player.ExecuteClientCommand("teammenu");
});
}

// Many hours of hard work went into this.
if (new List<ulong> { 76561198028510846, 76561198044886803, 76561198414501446 }.Contains(player.SteamID))
{
Expand Down
Loading