From 72a3535f3897ebc4a8849c1ec29135a07f950f09 Mon Sep 17 00:00:00 2001 From: MSWS Date: Tue, 13 Feb 2024 10:22:06 -0800 Subject: [PATCH] More work on LR --- .../LastRequestCommand.cs | 16 ++++++++++++++ .../LastRequests/KnifeFight.cs | 22 +++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 mod/Jailbreak.LastRequest/LastRequestCommand.cs diff --git a/mod/Jailbreak.LastRequest/LastRequestCommand.cs b/mod/Jailbreak.LastRequest/LastRequestCommand.cs new file mode 100644 index 00000000..7d31e661 --- /dev/null +++ b/mod/Jailbreak.LastRequest/LastRequestCommand.cs @@ -0,0 +1,16 @@ +using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core.Attributes.Registration; +using CounterStrikeSharp.API.Modules.Commands; +using Jailbreak.Public.Behaviors; + +namespace Jailbreak.LastRequest; + +public class LastRequestCommand : IPluginBehavior +{ + [ConsoleCommand("css_lr", "Start a last request as a prisoner")] + [CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)] + public void Command_LastRequest(CCSPlayerController? executor, CommandInfo info) + { + + } +} \ No newline at end of file diff --git a/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs b/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs index 70a4480b..9513889f 100644 --- a/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs +++ b/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs @@ -9,20 +9,38 @@ public class KnifeFight : AbstractLastRequest public KnifeFight(BasePlugin plugin, CCSPlayerController prisoner, CCSPlayerController guard) : base(plugin, prisoner, guard) { + plugin.RegisterEventHandler(OnPlayerDeath); + } + + public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) + { + if (@event.Userid != prisoner && @event.Userid != guard) + return HookResult.Continue; + + if (@event.Userid == prisoner) + End(LRResult.GuardWin); + else + End(LRResult.PrisonerWin); + return HookResult.Continue; } public override void Setup() { // Strip weapons, teleport T to CT + prisoner.RemoveWeapons(); + guard.RemoveWeapons(); + this.state = LRState.Pending; } public override void Execute() { - // Give knives + prisoner.GiveNamedItem("weapon_knife"); + guard.GiveNamedItem("weapon_knife"); + this.state = LRState.Active; } public override void End(LRResult result) { - // Slay the loser + this.state = LRState.Completed; } } \ No newline at end of file