diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 7ad9244a..85aba9b5 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -34,6 +34,35 @@ namespace ReallifeGamemode.Server.Commands { #region Todo + [Command("cuff", "~m~Benutzung: ~s~/cuff [ID]")] + public void CmdSncAnim(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; + + float rad = player.Heading * MathF.PI / 180; + Vector3 forward = new Vector3(player.Position.X + (1.2 * MathF.Sin(rad)), player.Position.Y + (1.2 * MathF.Cos(rad)), player.Position.Z); + + target.Position = forward; + + if (!target.HasAnimation("Cuffed")) + { + player.SyncAnimation("doArrest"); + target.SyncAnimation("getArrest"); + } + else + { + player.SyncAnimation("doUncuff"); + target.SyncAnimation("getUncuff"); + } + } + [Command("syncanim", "~m~Benutzung: ~s~/syncanim [animName]")] public void CmdSncAnim(Player player, string animName = null) { diff --git a/ReallifeGamemode.Server/Util/AnimationSync.cs b/ReallifeGamemode.Server/Util/AnimationSync.cs index 748591c7..4f33ea9e 100644 --- a/ReallifeGamemode.Server/Util/AnimationSync.cs +++ b/ReallifeGamemode.Server/Util/AnimationSync.cs @@ -22,6 +22,11 @@ namespace ReallifeGamemode.Server.Util player.SetSharedData("AnimationData", newAnimation); } + public static bool HasAnimation(this Player player, string animationName) + { + return player.HasData("Animation") && (player.GetData("AnimationData") == animationName); + } + public static void ClearAnimation(this Player player) { if (!player.HasData("Animation"))