Skip to content

Commit

Permalink
Added config to automatically make joining players join the queue
Browse files Browse the repository at this point in the history
  • Loading branch information
B3none committed Apr 14, 2024
1 parent a56b400 commit 0ad3d80
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
4 changes: 3 additions & 1 deletion RetakesPlugin/Modules/Configs/RetakesConfigData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

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

public int Version { get; set; } = CurrentVersion;
public int MinPlayers { get; set; } = 1;
public int MaxPlayers { get; set; } = 9;
public float TerroristRatio { get; set; } = 0.45f;
public int RoundsToScramble { get; set; } = 5;
Expand All @@ -19,4 +20,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.AddPlayerToQueue(player);

Check failure on line 512 in RetakesPlugin/RetakesPlugin.cs

View workflow job for this annotation

GitHub Actions / build

'QueueManager' does not contain a definition for 'AddPlayerToQueue' and no accessible extension method 'AddPlayerToQueue' accepting a first argument of type 'QueueManager' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 512 in RetakesPlugin/RetakesPlugin.cs

View workflow job for this annotation

GitHub Actions / build

'QueueManager' does not contain a definition for 'AddPlayerToQueue' and no accessible extension method 'AddPlayerToQueue' accepting a first argument of type 'QueueManager' could be found (are you missing a using directive or an assembly reference?)
}
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

0 comments on commit 0ad3d80

Please sign in to comment.