From 5ebdbb67ca124319a4170800defa96e0ccb49e53 Mon Sep 17 00:00:00 2001 From: kookroach Date: Tue, 6 Apr 2021 18:09:25 +0200 Subject: [PATCH] test --- ReallifeGamemode.Client/util/animationSync.ts | 10 ++++- .../Commands/AdminCommands.cs | 38 ++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Client/util/animationSync.ts b/ReallifeGamemode.Client/util/animationSync.ts index d7b21703..fc3b54f8 100644 --- a/ReallifeGamemode.Client/util/animationSync.ts +++ b/ReallifeGamemode.Client/util/animationSync.ts @@ -66,7 +66,7 @@ if (player == mp.players.local) { blockInput = true; } - } else if (!loop) { + } else if (!loop && player.isPlayingAnim(animDict, animName, 3)) { if (player == mp.players.local) { blockInput = false; mp.events.callRemote("CLIENT:ClearAnimationData", player); @@ -127,6 +127,14 @@ mp.events.callRemote("CLIENT:SET_InFrontOfPos", result); }); + mp.events.add("SERVER:GetInFrontOfPlayer", (entity: PlayerMp) => { + let player = mp.players.local; + let result = xyInFrontOfPos(entity.position, entity.heading, 0.5); + result.z = player.position.z; + mp.players.local.heading = entity.heading; + mp.players.local.position = result; + }); + function xyInFrontOfPos(pos, heading, dist): Vector3Mp { heading *= Math.PI / 180 pos.x += (dist * Math.sin(-heading)) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index b121085a..880b840f 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -34,6 +34,39 @@ namespace ReallifeGamemode.Server.Commands { #region Todo + [Command("test_cuff1")] + public void TestCuff1(Player player, string nameOrId) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + Player target = PlayerService.GetPlayerByNameOrId(nameOrId); + if (target.Id == player.Id) + return; + + Vector3 front = player.GetInFrontOfPosition(); + front.Z = player.Position.Z; + target.Position = front; + target.Heading = player.Heading; + } + + [Command("test_cuff2")] + public void TestCuff2(Player player, string nameOrId) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + Player target = PlayerService.GetPlayerByNameOrId(nameOrId); + if (target.Id == player.Id) + return; + + target.TriggerEvent("SERVER:GetInFrontOfPlayer", player); + } + [Command("cuff", "~m~Benutzung: ~s~/cuff [ID]")] public void CmdCuffTest(Player player, string nameOrId) { @@ -46,7 +79,10 @@ namespace ReallifeGamemode.Server.Commands if (target.Id == player.Id) return; - target.Position = player.GetInFrontOfPosition(); + Vector3 front = player.GetInFrontOfPosition(); + front.Z = player.Position.Z; + + target.Position = front; target.Heading = player.Heading; if (!target.HasAnimation("Cuffed"))