Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
feat: Option to reset killstreaks for alive players
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Apr 13, 2024
1 parent d903d9a commit 6c54827
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
-- 2023.04.13 - V4.1.3

- feat: Option to reset killstreaks for alive players
- fix: Top command not prints properly
- fix: Points for dying not working

-- 2023.04.12 - V4.1.2

- fix: AutoPurge query
- fix: RoundStart error log (#166)
- fix: Delete invalid players on save-all
- fix: RankTop not updating instantly (#166)
- fix: RankTop position display problems (#166)

-- 2023.04.11 - V4.1.1

Expand Down
33 changes: 18 additions & 15 deletions K4-System/src/Module/Rank/RankCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,28 +178,31 @@ public void OnCommandTop(CCSPlayerController? player, CommandInfo info)

Task.Run(async () =>
{
await plugin.SaveAllPlayersDataAsync();
List<(int points, string name)>? rankData = await FetchTopDataAsync(printCount);
if (rankData?.Count > 0)
Server.NextFrame(() =>
{
for (int i = 0; i < rankData.Count; i++)
if (!k4player.IsValid || !k4player.IsPlayer)
return;
if (rankData?.Count > 0)
{
int points = rankData[i].points;
string name = rankData[i].name;
for (int i = 0; i < rankData.Count; i++)
{
int points = rankData[i].points;
string name = rankData[i].name;
Rank rank = GetPlayerRank(points);
Rank rank = GetPlayerRank(points);
Server.NextFrame(() =>
{
player!.PrintToChat($" {plugin.Localizer["k4.ranks.top.line", i + 1, rank.Color, rank.Name, name, points]}");
});
k4player.Controller.PrintToChat($" {plugin.Localizer["k4.ranks.top.line", i + 1, rank.Color, rank.Name, name, points]}");
}
}
}
else
{
player!.PrintToChat($" {plugin.Localizer["k4.general.prefix"]} {plugin.Localizer["k4.ranks.top.notfound", printCount]}");
}
else
{
k4player.Controller.PrintToChat($" {plugin.Localizer["k4.general.prefix"]} {plugin.Localizer["k4.ranks.top.notfound", printCount]}");
}
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion K4-System/src/Module/Rank/RankEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void Initialize_Events()
K4Player? k4attacker = plugin.GetK4Player(@event.Attacker);
if (!k4victim.IsPlayer)
if (k4victim.IsPlayer)
{
k4victim.KillStreak = (0, DateTime.Now);
Expand Down
2 changes: 1 addition & 1 deletion K4-System/src/Module/Rank/RankFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void BeforeRoundEnd(int winnerTeam)
if (!k4player.IsValid || !k4player.IsPlayer)
continue;

if (!k4player.Controller.PawnIsAlive)
if (!k4player.Controller.PawnIsAlive || Config.RankSettings.KillstreakResetOnRoundEnd)
k4player.KillStreak = (0, DateTime.Now);

RankData? playerData = k4player.rankData;
Expand Down
3 changes: 3 additions & 0 deletions K4-System/src/Plugin/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public sealed class StatisticSettings

public sealed class RankSettings
{
[JsonPropertyName("killstreak-reset-on-round-end")]
public bool KillstreakResetOnRoundEnd { get; set; } = false;

[JsonPropertyName("start-points")]
public int StartPoints { get; set; } = 0;

Expand Down
2 changes: 1 addition & 1 deletion K4-System/src/Plugin/PluginManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed partial class Plugin : BasePlugin

public override string ModuleAuthor => "K4ryuu";

public override string ModuleVersion => "4.1.2 " +
public override string ModuleVersion => "4.1.3 " +
#if RELEASE
"(release)";
#else
Expand Down

0 comments on commit 6c54827

Please sign in to comment.