Skip to content

Commit

Permalink
Revert "Add weapon drops to logs" (#125)
Browse files Browse the repository at this point in the history
Reverts #112 - sigs out of date
  • Loading branch information
jithatsonei authored Apr 27, 2024
2 parents bfd3002 + 279600f commit d4d7b29
Showing 1 changed file with 1 addition and 57 deletions.
58 changes: 1 addition & 57 deletions mod/Jailbreak.Logs/Listeners/LogEntityListeners.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;

using Jailbreak.Formatting.Views;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
Expand All @@ -16,61 +15,6 @@ public class LogEntityListeners : IPluginBehavior
public LogEntityListeners(IRichLogService logs)
{
_logs = logs;
OnDropGun();
}

private static MemoryFunctionVoid<CBasePlayerPawn, CBasePlayerWeapon, IntPtr> WeaponDrop = new( @"\x55\x48\x89\xE5\x41\x56\x41\x55\x49\x89\xD5\x41\x54\x49\x89\xFC\x53\x48\x89\xF3\xE8\x2A\x2A\x2A\x2A" );

private void OnDropGun()
{
WeaponDrop.Hook(hook =>
{
var pawn = hook.GetParam<CBasePlayerPawn>(0);
var weapon = hook.GetParam<CBasePlayerWeapon>(1);

if (!pawn.IsValid) return HookResult.Continue;
if (pawn.Controller.Value == null || !pawn.Controller.IsValid) return HookResult.Continue;

var player = (CCSPlayerController)pawn.Controller.Value;

if (player.Team != CsTeam.CounterTerrorist) return HookResult.Changed;

_logs.Append(_logs.Player(player), $"dropped weapon: {weapon.DesignerName}");
return HookResult.Continue;
}, HookMode.Pre);
}

[GameEventHandler]
public void OnItemPickup(EventItemPickup @event, GameEventInfo info)
{
var player = @event.Userid;
if (!player.IsReal())
return;

if (!player.IsValid)
return;

if (player.Team != CsTeam.Terrorist) return;


Server.NextFrame(() =>
{
var pawn = player.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid) return;
var weaponServices = pawn.WeaponServices;
if (weaponServices == null) return;

foreach (var weaponHandle in weaponServices.MyWeapons.Where(handle => handle.IsValid && handle.Value != null).ToList())
{
if (!weaponHandle.Value.DesignerName.Equals(@event.Item)) continue;

var owner = weaponHandle.Value.OwnerEntity.Value.As<CCSPlayerController>();
if (owner.Team != CsTeam.CounterTerrorist) return;
_logs.Append(_logs.Player(player), $"picked up an {_logs.Player(owner)}s item: {weaponHandle.Value.DesignerName}");

}
});

}

[EntityOutputHook("func_button", "OnPressed")]
Expand Down

0 comments on commit d4d7b29

Please sign in to comment.