Skip to content

Commit

Permalink
Updated IsValidPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
B3none committed Jan 28, 2024
1 parent 1a11239 commit a4363fd
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ClutchAnnouncePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
{
Console.WriteLine($"{LogPrefix}OnRoundEnd event fired!");

if (_clutchPlayer != null && IsValidPlayer(_clutchPlayer) && (CsTeam)@event.Winner == _clutchTeam)
if (IsValidPlayer(_clutchPlayer) && (CsTeam)@event.Winner == _clutchTeam)
{
Server.PrintToChatAll(MessagePrefix + _translator["clutch_announce.clutched", _clutchPlayer.PlayerName, _opponents]);

Check warning on line 69 in ClutchAnnouncePlugin.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 69 in ClutchAnnouncePlugin.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}
Expand Down Expand Up @@ -118,11 +118,12 @@ private void CheckAlive()
}

// Helpers
private static bool IsValidPlayer(CCSPlayerController player)
private static bool IsValidPlayer(CCSPlayerController? player)
{
return player.IsValid
&& player.PlayerPawn.IsValid
&& player.PlayerPawn.Value != null
&& player.PlayerPawn.Value.IsValid;
return player != null
&& player.IsValid
&& player.PlayerPawn.IsValid
&& player.PlayerPawn.Value != null
&& player.PlayerPawn.Value.IsValid;
}
}

0 comments on commit a4363fd

Please sign in to comment.