Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Commit

Permalink
fix: Negative points
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Nov 9, 2023
1 parent 52e0bee commit d9b34cb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/K4ryuuSimpleRanks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,10 @@ public void OnCommandRemovePoints(CCSPlayerController? player, CommandInfo comma
Log($" {CFG.config.ChatPrefix} {ChatColors.LightRed}{player.PlayerName} has removed {parsedInt} points from {target.PlayerName}.");

PlayerSummaries[player].Points -= parsedInt;

if (PlayerSummaries[player].Points < 0)
PlayerSummaries[player].Points = 0;

CheckNewRank(player);

return;
Expand Down Expand Up @@ -825,6 +829,10 @@ public void ModifyClientPoints(CCSPlayerController player, CHANGE_MODE mode, int
{
player.PrintToChat($" {CFG.config.ChatPrefix} {ChatColors.White}Points: {ChatColors.LightRed}{PlayerSummaries[player].Points}[-{amount} {reason}]");
PlayerSummaries[player].Points -= amount;

if (PlayerSummaries[player].Points < 0)
PlayerSummaries[player].Points = 0;

MySql!.ExecuteNonQueryAsync($"UPDATE `k4ranks` SET `points` = GREATEST(`points` - {amount}, 0) WHERE `steam_id` = {player.SteamID};");
break;
}
Expand Down

0 comments on commit d9b34cb

Please sign in to comment.