Skip to content

Commit

Permalink
Better duration check
Browse files Browse the repository at this point in the history
  • Loading branch information
Dliix66 committed Apr 24, 2024
1 parent fb251aa commit a0b2e59
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Commands/basebans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,19 @@ private bool CheckValidBan(CCSPlayerController? caller, int duration)
{
bool validCaller = caller != null && caller.IsValid;

if (duration > Config.MaxBanDuration)
bool canPermBan = validCaller && AdminManager.PlayerHasPermissions(caller, "@css/permban");

if (duration > Config.MaxBanDuration && canPermBan == false)
{
if (validCaller)
caller.PrintToChat($"[Simple Admin] Ban duration cannot exceed {Config.MaxBanDuration} minutes.");

Check warning on line 390 in Commands/basebans.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 390 in Commands/basebans.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
return false;
}

if (duration == 0 && validCaller && AdminManager.PlayerHasPermissions(caller, "@css/permban") == false)
if (duration == 0 && canPermBan == false)
{
caller.PrintToChat($"[Simple Admin] You do not have the right to permanently ban.");
if (validCaller)
caller.PrintToChat($"[Simple Admin] You do not have the right to permanently ban.");

Check warning on line 397 in Commands/basebans.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 397 in Commands/basebans.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
return false;
}

Expand Down

0 comments on commit a0b2e59

Please sign in to comment.