working weapon concealment

This commit is contained in:
2026-08-10 16:59:45 +02:00
parent 4e9500f0ea
commit 9a23169b6b
13 changed files with 927 additions and 66 deletions

View File

@@ -24,11 +24,11 @@ public sealed class SendProxyWeaponVisibilityPlugin : BasePlugin
public override void Load(bool hotReload)
{
_sendProxy = new SendProxyNative(GetSendProxyLibraryPath());
_sendProxy = SendProxyNative.FromGameDirectory(Server.GameDirectory);
_syncTimer = AddTimer(0.25f, SyncRules, TimerFlags.REPEAT);
RegisterListener<Listeners.OnEntityCreated>(_ => Server.NextFrame(SyncRules));
RegisterListener<Listeners.OnEntityDeleted>(_ => Server.NextFrame(SyncRules));
SyncRules();
Server.NextFrame(SyncRules);
}
public override void Unload(bool hotReload)
@@ -45,9 +45,17 @@ public sealed class SendProxyWeaponVisibilityPlugin : BasePlugin
return;
var desired = new Dictionary<RuleKey, RuleValue>();
var viewers = Utilities.GetPlayers()
.Where(player => player.IsValid && !player.IsBot && !player.IsHLTV)
.ToArray();
CCSPlayerController[] viewers;
try
{
viewers = Utilities.GetPlayers()
.Where(player => player.IsValid && !player.IsBot && !player.IsHLTV)
.ToArray();
}
catch (NativeException)
{
return;
}
AddHealthRules(desired, viewers);
@@ -211,14 +219,6 @@ public sealed class SendProxyWeaponVisibilityPlugin : BasePlugin
_activeRules.Clear();
}
private string GetSendProxyLibraryPath()
{
string libraryPath = Path.Combine(Server.GameDirectory, "addons", "sendproxy", "bin", "linuxsteamrt64", "sendproxy.so");
if (!File.Exists(libraryPath))
throw new FileNotFoundException("SendProxy Metamod addon was not found. Install it under game/csgo/addons/sendproxy.", libraryPath);
return libraryPath;
}
private readonly record struct RuleKey(int RecipientSlot, int EntityIndex, string ClassName, string FieldPath);
private readonly record struct RuleValue(byte[] Bytes)