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

Commit

Permalink
Patch V4.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Apr 16, 2024
1 parent 0ed8c5d commit 66b4d41
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-- 2023.04.16 - V4.1.5

- fix: Scoreboard rank missmatch of flag based ones
- fix: LVLRanks MySQL SteamIDs
- fix: Death stats not counted properly

-- 2023.04.14 - V4.1.4

- fix: MySQL error logging non-thread problems
Expand Down
19 changes: 16 additions & 3 deletions K4-System/src/Module/Rank/RankCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,29 @@ public void OnCommandTop(CCSPlayerController? player, CommandInfo info)
printCount = Math.Clamp(parsedInt, 1, 25);
}

Logger.LogInformation($"Player {k4player.PlayerName} requested top {printCount} players.");

Task.Run(async () =>
{
Console.WriteLine("Saving all players data");
await plugin.SaveAllPlayersDataAsync();
Console.WriteLine("Fetching top data");
List<(int points, string name)>? rankData = await FetchTopDataAsync(printCount);
Console.WriteLine("Fetched top data, waiting tick to print to chat.");
Server.NextFrame(() =>
{
Console.WriteLine("Printing top data to chat.");
if (!k4player.IsValid || !k4player.IsPlayer)
return;
Console.WriteLine("Player is valid and is player.");
if (rankData?.Count > 0)
{
for (int i = 0; i < rankData.Count; i++)
Expand All @@ -195,12 +208,12 @@ public void OnCommandTop(CCSPlayerController? player, CommandInfo info)
Rank rank = GetPlayerRank(points);
k4player.Controller.PrintToChat($" {plugin.Localizer["k4.ranks.top.line", i + 1, rank.Color, rank.Name, name, points]}");
player!.PrintToChat($" {plugin.Localizer["k4.ranks.top.line", i + 1, rank.Color, rank.Name, name, points]}");
}
}
else
{
k4player.Controller.PrintToChat($" {plugin.Localizer["k4.general.prefix"]} {plugin.Localizer["k4.ranks.top.notfound", printCount]}");
player!.PrintToChat($" {plugin.Localizer["k4.general.prefix"]} {plugin.Localizer["k4.ranks.top.notfound", printCount]}");
}
});
});
Expand All @@ -223,7 +236,7 @@ public void OnCommandTop(CCSPlayerController? player, CommandInfo info)
}
catch (Exception ex)
{
Logger.LogError($"A problem occurred while fetching top data: {ex.Message}");
Server.NextFrame(() => { Logger.LogError($"A problem occurred while fetching top data: {ex.Message}"); });
return null;
}
}
Expand Down
18 changes: 4 additions & 14 deletions K4-System/src/Module/Rank/RankFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void ModifyPlayerPoints(K4Player k4player, int amount, string reason, str
}
catch (Exception ex)
{
Logger.LogError($"A problem occurred while fetching player place and count: {ex.Message}");
Server.NextFrame(() => Logger.LogError($"A problem occurred while fetching player place and count: {ex.Message}"));
}

return (0, 0);
Expand Down Expand Up @@ -255,20 +255,10 @@ public void SetPlayerClanTag(K4Player k4player)
if (adminSettings.ClanTag == null)
continue;

switch (adminSettings.Permission[0])
if (Plugin.PlayerHasPermission(k4player, adminSettings.Permission))
{
case '@':
if (AdminManager.PlayerHasPermissions(k4player.Controller, adminSettings.Permission))
tag = adminSettings.ClanTag;
break;
case '#':
if (AdminManager.PlayerInGroup(k4player.Controller, adminSettings.Permission))
tag = adminSettings.ClanTag;
break;
default:
if (AdminManager.PlayerHasCommandOverride(k4player.Controller, adminSettings.Permission))
tag = adminSettings.ClanTag;
break;
tag = adminSettings.ClanTag;
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion K4-System/src/Module/Stat/StatEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void Initialize_Events()
if (!k4victim.IsPlayer && !Config.StatisticSettings.StatsForBots)
return HookResult.Continue;
if (!k4victim.IsPlayer)
if (k4victim.IsPlayer)
{
ModifyPlayerStats(k4victim, "deaths", 1);
}
Expand Down
15 changes: 1 addition & 14 deletions K4-System/src/Module/Utils/UtilsCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void OnCommandAdmins(CCSPlayerController? player, CommandInfo info)
if (entry.ListColor == null)
continue;

if (PlayerHasPermission(k4player, entry.Permission))
if (Plugin.PlayerHasPermission(k4player, entry.Permission))
{
adminList.Add($"{plugin.ApplyPrefixColors(entry.ListColor ?? "default")}{k4player.PlayerName}");
break;
Expand All @@ -53,19 +53,6 @@ public void OnCommandAdmins(CCSPlayerController? player, CommandInfo info)
}
else
info.ReplyToCommand($" {plugin.Localizer["k4.adminlist.no-admins"]}");

bool PlayerHasPermission(K4Player k4player, string permission)
{
switch (permission[0])
{
case '@':
return AdminManager.PlayerHasPermissions(k4player.Controller, permission);
case '#':
return AdminManager.PlayerInGroup(k4player.Controller, permission);
default:
return AdminManager.PlayerHasCommandOverride(k4player.Controller, permission);
}
}
}
}
}
3 changes: 2 additions & 1 deletion K4-System/src/Plugin/PluginDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities;
using Dapper;
using K4System.Models;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -170,7 +171,7 @@ ON DUPLICATE KEY UPDATE

var parameters = new
{
SteamId = k4player.SteamID.ToString().Replace("STEAM_0", "STEAM_1"),
SteamId = new SteamID(k4player.SteamID).SteamId2.Replace("STEAM_0", "STEAM_1"),
k4player.PlayerName,
Kills = k4player.statData?.StatFields["kills"] ?? 0,
Deaths = k4player.statData?.StatFields["deaths"] ?? 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.4 " +
public override string ModuleVersion => "4.1.5 " +
#if RELEASE
"(release)";
#else
Expand Down
13 changes: 13 additions & 0 deletions K4-System/src/Plugin/PluginStock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,18 @@ public bool CommandHelper(CCSPlayerController? player, CommandInfo info, Command
{
return K4Players.FirstOrDefault(player => player.Controller == playerController);
}

public static bool PlayerHasPermission(K4Player k4player, string permission)
{
switch (permission[0])
{
case '@':
return AdminManager.PlayerHasPermissions(k4player.Controller, permission);
case '#':
return AdminManager.PlayerInGroup(k4player.Controller, permission);
default:
return AdminManager.PlayerHasCommandOverride(k4player.Controller, permission);
}
}
}
}

0 comments on commit 66b4d41

Please sign in to comment.