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

Commit 1ba8d57

Browse files
committed
feat: Center text flag support (#23)
1 parent 282300d commit 1ba8d57

2 files changed

Lines changed: 46 additions & 5 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
-- 2024.03.23 - V2.1.1
1+
-- 2024.03.23 - V2.2.0
22

3-
- fix: Team damage info with friendly fire off
3+
- feat: Center text flag support (#23)
4+
- fix: Team damage info with friendly fire off (#22)
45

56
-- 2024.02.28 - V2.1.0
67

src/K4ryuuDamageInfo.cs

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
using CounterStrikeSharp.API;
44
using CounterStrikeSharp.API.Core;
55
using CounterStrikeSharp.API.Core.Attributes;
6+
using CounterStrikeSharp.API.Modules.Admin;
67
using CounterStrikeSharp.API.Modules.Cvars;
8+
using CounterStrikeSharp.API.Modules.Entities;
79
using CounterStrikeSharp.API.Modules.Utils;
810
using Microsoft.Extensions.Logging;
911

@@ -35,15 +37,24 @@ public sealed class PluginConfig : BasePluginConfig
3537
[JsonPropertyName("norounds-mode")]
3638
public bool NoRoundsMode { get; set; } = false;
3739

40+
[JsonPropertyName("center-info-flags")]
41+
public List<string> CenterInfoFlags { get; set; } = new List<string>
42+
{
43+
"@myplugin/can-see-permission",
44+
"#myplugin/can-see-group",
45+
"can-see-override",
46+
"leave-empty-so-let-everyone-see"
47+
};
48+
3849
[JsonPropertyName("ConfigVersion")]
39-
public override int Version { get; set; } = 2;
50+
public override int Version { get; set; } = 3;
4051
}
4152

4253
[MinimumApiVersion(153)]
4354
public class DamageInfoPlugin : BasePlugin, IPluginConfig<PluginConfig>
4455
{
4556
public override string ModuleName => "Damage Info";
46-
public override string ModuleVersion => "2.1.1";
57+
public override string ModuleVersion => "2.2.0";
4758
public override string ModuleAuthor => "K4ryuu";
4859

4960
public required PluginConfig Config { get; set; } = new PluginConfig();
@@ -149,7 +160,7 @@ private HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)
149160
victim.PrintToConsole(Localizer["phrases.console.inverse", attacker.PlayerName, damageToHeath, damageToArmor, hitgroup]);
150161
}
151162

152-
if (Config.CenterDamageInfo)
163+
if (Config.CenterDamageInfo && PlayerHasPermissions(attacker))
153164
{
154165

155166
if (!recentDamages.ContainsKey(attacker.Slot))
@@ -367,5 +378,34 @@ private class RecentDamage
367378
public int TotalDamage;
368379
public DateTime LastDamageTime;
369380
}
381+
382+
public bool PlayerHasPermissions(CCSPlayerController player)
383+
{
384+
if (Config.CenterInfoFlags.Count == 0)
385+
return true;
386+
387+
bool hasPermission = false;
388+
389+
foreach (string checkPermission in Config.CenterInfoFlags)
390+
{
391+
switch (checkPermission[0])
392+
{
393+
case '@':
394+
if (AdminManager.PlayerHasPermissions(player, checkPermission))
395+
hasPermission = true;
396+
break;
397+
case '#':
398+
if (AdminManager.PlayerInGroup(player, checkPermission))
399+
hasPermission = true;
400+
break;
401+
default:
402+
if (AdminManager.PlayerHasCommandOverride(player, checkPermission))
403+
hasPermission = true;
404+
break;
405+
}
406+
}
407+
408+
return hasPermission;
409+
}
370410
}
371411
}

0 commit comments

Comments
 (0)