Skip to content
This repository was archived by the owner on Jan 25, 2025. It is now read-only.

Commit 66b4d41

Browse files
committed
Patch V4.1.5
1 parent 0ed8c5d commit 66b4d41

File tree

8 files changed

+44
-34
lines changed

8 files changed

+44
-34
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
-- 2023.04.16 - V4.1.5
2+
3+
- fix: Scoreboard rank missmatch of flag based ones
4+
- fix: LVLRanks MySQL SteamIDs
5+
- fix: Death stats not counted properly
6+
17
-- 2023.04.14 - V4.1.4
28

39
- fix: MySQL error logging non-thread problems

K4-System/src/Module/Rank/RankCommands.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,29 @@ public void OnCommandTop(CCSPlayerController? player, CommandInfo info)
176176
printCount = Math.Clamp(parsedInt, 1, 25);
177177
}
178178

179+
Logger.LogInformation($"Player {k4player.PlayerName} requested top {printCount} players.");
180+
179181
Task.Run(async () =>
180182
{
183+
Console.WriteLine("Saving all players data");
184+
181185
await plugin.SaveAllPlayersDataAsync();
186+
187+
Console.WriteLine("Fetching top data");
188+
182189
List<(int points, string name)>? rankData = await FetchTopDataAsync(printCount);
183190

191+
Console.WriteLine("Fetched top data, waiting tick to print to chat.");
192+
184193
Server.NextFrame(() =>
185194
{
195+
Console.WriteLine("Printing top data to chat.");
196+
186197
if (!k4player.IsValid || !k4player.IsPlayer)
187198
return;
188199

200+
Console.WriteLine("Player is valid and is player.");
201+
189202
if (rankData?.Count > 0)
190203
{
191204
for (int i = 0; i < rankData.Count; i++)
@@ -195,12 +208,12 @@ public void OnCommandTop(CCSPlayerController? player, CommandInfo info)
195208

196209
Rank rank = GetPlayerRank(points);
197210

198-
k4player.Controller.PrintToChat($" {plugin.Localizer["k4.ranks.top.line", i + 1, rank.Color, rank.Name, name, points]}");
211+
player!.PrintToChat($" {plugin.Localizer["k4.ranks.top.line", i + 1, rank.Color, rank.Name, name, points]}");
199212
}
200213
}
201214
else
202215
{
203-
k4player.Controller.PrintToChat($" {plugin.Localizer["k4.general.prefix"]} {plugin.Localizer["k4.ranks.top.notfound", printCount]}");
216+
player!.PrintToChat($" {plugin.Localizer["k4.general.prefix"]} {plugin.Localizer["k4.ranks.top.notfound", printCount]}");
204217
}
205218
});
206219
});
@@ -223,7 +236,7 @@ public void OnCommandTop(CCSPlayerController? player, CommandInfo info)
223236
}
224237
catch (Exception ex)
225238
{
226-
Logger.LogError($"A problem occurred while fetching top data: {ex.Message}");
239+
Server.NextFrame(() => { Logger.LogError($"A problem occurred while fetching top data: {ex.Message}"); });
227240
return null;
228241
}
229242
}

K4-System/src/Module/Rank/RankFunctions.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public void ModifyPlayerPoints(K4Player k4player, int amount, string reason, str
211211
}
212212
catch (Exception ex)
213213
{
214-
Logger.LogError($"A problem occurred while fetching player place and count: {ex.Message}");
214+
Server.NextFrame(() => Logger.LogError($"A problem occurred while fetching player place and count: {ex.Message}"));
215215
}
216216

217217
return (0, 0);
@@ -255,20 +255,10 @@ public void SetPlayerClanTag(K4Player k4player)
255255
if (adminSettings.ClanTag == null)
256256
continue;
257257

258-
switch (adminSettings.Permission[0])
258+
if (Plugin.PlayerHasPermission(k4player, adminSettings.Permission))
259259
{
260-
case '@':
261-
if (AdminManager.PlayerHasPermissions(k4player.Controller, adminSettings.Permission))
262-
tag = adminSettings.ClanTag;
263-
break;
264-
case '#':
265-
if (AdminManager.PlayerInGroup(k4player.Controller, adminSettings.Permission))
266-
tag = adminSettings.ClanTag;
267-
break;
268-
default:
269-
if (AdminManager.PlayerHasCommandOverride(k4player.Controller, adminSettings.Permission))
270-
tag = adminSettings.ClanTag;
271-
break;
260+
tag = adminSettings.ClanTag;
261+
break;
272262
}
273263
}
274264
}

K4-System/src/Module/Stat/StatEvents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void Initialize_Events()
2323
if (!k4victim.IsPlayer && !Config.StatisticSettings.StatsForBots)
2424
return HookResult.Continue;
2525

26-
if (!k4victim.IsPlayer)
26+
if (k4victim.IsPlayer)
2727
{
2828
ModifyPlayerStats(k4victim, "deaths", 1);
2929
}

K4-System/src/Module/Utils/UtilsCommands.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void OnCommandAdmins(CCSPlayerController? player, CommandInfo info)
3636
if (entry.ListColor == null)
3737
continue;
3838

39-
if (PlayerHasPermission(k4player, entry.Permission))
39+
if (Plugin.PlayerHasPermission(k4player, entry.Permission))
4040
{
4141
adminList.Add($"{plugin.ApplyPrefixColors(entry.ListColor ?? "default")}{k4player.PlayerName}");
4242
break;
@@ -53,19 +53,6 @@ public void OnCommandAdmins(CCSPlayerController? player, CommandInfo info)
5353
}
5454
else
5555
info.ReplyToCommand($" {plugin.Localizer["k4.adminlist.no-admins"]}");
56-
57-
bool PlayerHasPermission(K4Player k4player, string permission)
58-
{
59-
switch (permission[0])
60-
{
61-
case '@':
62-
return AdminManager.PlayerHasPermissions(k4player.Controller, permission);
63-
case '#':
64-
return AdminManager.PlayerInGroup(k4player.Controller, permission);
65-
default:
66-
return AdminManager.PlayerHasCommandOverride(k4player.Controller, permission);
67-
}
68-
}
6956
}
7057
}
7158
}

K4-System/src/Plugin/PluginDatabase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Text;
44
using CounterStrikeSharp.API;
55
using CounterStrikeSharp.API.Core;
6+
using CounterStrikeSharp.API.Modules.Entities;
67
using Dapper;
78
using K4System.Models;
89
using Microsoft.Extensions.Logging;
@@ -170,7 +171,7 @@ ON DUPLICATE KEY UPDATE
170171

171172
var parameters = new
172173
{
173-
SteamId = k4player.SteamID.ToString().Replace("STEAM_0", "STEAM_1"),
174+
SteamId = new SteamID(k4player.SteamID).SteamId2.Replace("STEAM_0", "STEAM_1"),
174175
k4player.PlayerName,
175176
Kills = k4player.statData?.StatFields["kills"] ?? 0,
176177
Deaths = k4player.statData?.StatFields["deaths"] ?? 0,

K4-System/src/Plugin/PluginManifest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public sealed partial class Plugin : BasePlugin
1010

1111
public override string ModuleAuthor => "K4ryuu";
1212

13-
public override string ModuleVersion => "4.1.4 " +
13+
public override string ModuleVersion => "4.1.5 " +
1414
#if RELEASE
1515
"(release)";
1616
#else

K4-System/src/Plugin/PluginStock.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,18 @@ public bool CommandHelper(CCSPlayerController? player, CommandInfo info, Command
8181
{
8282
return K4Players.FirstOrDefault(player => player.Controller == playerController);
8383
}
84+
85+
public static bool PlayerHasPermission(K4Player k4player, string permission)
86+
{
87+
switch (permission[0])
88+
{
89+
case '@':
90+
return AdminManager.PlayerHasPermissions(k4player.Controller, permission);
91+
case '#':
92+
return AdminManager.PlayerInGroup(k4player.Controller, permission);
93+
default:
94+
return AdminManager.PlayerHasCommandOverride(k4player.Controller, permission);
95+
}
96+
}
8497
}
8598
}

0 commit comments

Comments
 (0)