Skip to content

Commit

Permalink
Skip Commander Left Msgs if Team is Elimianted
Browse files Browse the repository at this point in the history
- Skips the messages for the commander left due to disconnect or switched to infantry when the team that was commanded was eliminated from the round
  • Loading branch information
data-bomb committed Feb 18, 2024
1 parent 3c503dc commit d6bc293
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Si_CommManagement/Si_CmdrMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You should have received a copy of the GNU General Public License
using SilicaAdminMod;
using System.Linq;

[assembly: MelonInfo(typeof(CommanderManager), "Commander Management", "1.4.7", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonInfo(typeof(CommanderManager), "Commander Management", "1.4.8", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonGame("Bohemia Interactive", "Silica")]
[assembly: MelonOptionalDependencies("Admin Mod")]

Expand Down Expand Up @@ -783,7 +783,8 @@ public static void Prefix(GameMode __instance, Player __0)

if (GameMode.CurrentGameMode.Started && GameMode.CurrentGameMode.GameBegun)
{
if (__0.IsCommander)
// don't display message if the team has since been eliminated
if (__0.IsCommander && __0.Team.NumMajorStructures > 0)
{
HelperMethods.ReplyToCommand_Player(__0, "left commander position vacant by disconnecting");
}
Expand All @@ -803,7 +804,7 @@ public static void Postfix(GameMode __instance, Unit __result, Player __0, Unity
{
try
{
if (teamswapCommanderChecks == null || __0 == null)
if (teamswapCommanderChecks == null || __0 == null || __0.Team == null)
{
return;
}
Expand All @@ -826,6 +827,13 @@ public static void Postfix(GameMode __instance, Unit __result, Player __0, Unity
{
Team departingTeam = Team.Teams[commanderSwappedTeamIndex];
teamswapCommanderChecks[commanderSwappedTeamIndex] = null;

// don't display if the team has been eliminated
if (departingTeam.NumMajorStructures <= 0)
{
return;
}

HelperMethods.ReplyToCommand_Player(__0, "left commander position vacant for " + HelperMethods.GetTeamColor(departingTeam) + departingTeam.TeamName + HelperMethods.defaultColor + " by switching to infantry");
}
}
Expand Down

0 comments on commit d6bc293

Please sign in to comment.