diff --git a/ReallifeGamemode.Client/util/animationSync.ts b/ReallifeGamemode.Client/util/animationSync.ts index f0e36c15..bc2f608d 100644 --- a/ReallifeGamemode.Client/util/animationSync.ts +++ b/ReallifeGamemode.Client/util/animationSync.ts @@ -1,5 +1,6 @@ export default function animationSync() { let blockInput = false; + let animationBreakTimer; mp.events.add("SERVER:LoadAnimations", () => { animationSyncData.register("Cuffed", "mp_arresting", "idle", -1, true, 50); @@ -11,6 +12,10 @@ animationSyncData.register("carryBox", "anim@heists@box_carry@", "idle", -1, true, 50); }); + const animationBreakMessage = [ + { animName: "Cuffed", msg: "Handschellen gebrochen." } + ]; + const animationSyncData = { animations: [], @@ -76,11 +81,16 @@ }); }, 100); - mp.events.addDataHandler("AnimationData", (entity: PlayerMp, string) => { + mp.events.addDataHandler("AnimationData", (entity, string) => { entity.clearTasksImmediately(); + + if (animationBreakTimer) { + clearInterval(animationBreakTimer); + animationBreakTimer = null; + } + if (string == null) { blockInput = false; - return; } @@ -96,12 +106,9 @@ mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1) }); - let b = setInterval(function () { - mp.events.callRemote("CLIENT:ClearAnimationData", entity); - if (name == "Cuffed" || name == "cuffed") - mp.events.call("renderTextOnScreen", "Handschellen gebrochen."); - clearInterval(b); - }, 120000); + if (mp.players.local == entity && loop) { + animationBreakTimer = setInterval(() => breakAnimation(entity, id), 120000); + } if (!loop) { let a = setInterval(function () { @@ -113,6 +120,17 @@ } }); + function breakAnimation(entity, id) { + mp.events.callRemote("CLIENT:ClearAnimationData", entity); + let { animName, msg } = animationBreakMessage.find(c => mp.game.joaat(c.animName) == id) + + if (msg) + mp.events.call("renderTextOnScreen", msg); + + clearInterval(animationBreakTimer); + animationBreakTimer = null; + } + mp.events.add("render", () => { if (blockInput) { mp.game.controls.disableControlAction(32, 25, true); diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index e4ae58b3..041f31dc 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -1205,7 +1205,7 @@ namespace ReallifeGamemode.Server.Commands [Command("respawnvehicle", "~m~Benutzung: ~s~/respawnvehicle (Db ID)", Alias = "rveh")] public void CmdAdminRespawnVehicle(Player player, int id = -1) { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) //change back to Admin { ChatService.NotAuthorized(player); return; diff --git a/ReallifeGamemode.Server/Commands/FactionCommands.cs b/ReallifeGamemode.Server/Commands/FactionCommands.cs index da4d3316..358cb273 100644 --- a/ReallifeGamemode.Server/Commands/FactionCommands.cs +++ b/ReallifeGamemode.Server/Commands/FactionCommands.cs @@ -426,21 +426,7 @@ namespace ReallifeGamemode.Server.Commands if (nearestCuffPlayer is null) return; - nearestCuffPlayer.SetInFrontOf(player); - nearestCuffPlayer.Heading = player.Heading; - - if (!nearestCuffPlayer.HasAnimation("Cuffed")) - { - player.SyncAnimation("doArrest"); - nearestCuffPlayer.SyncAnimation(new List() { "getArrest", "Cuffed" }); - player.AddAttachment("handcuffs", false); - } - else - { - player.AddAttachment("handcuffs", true); - player.SyncAnimation("doUncuff"); - nearestCuffPlayer.SyncAnimation("getUncuff"); - } + player.CuffPlayer(nearestCuffPlayer); } [Command("wanted", "~m~Benutzung: ~s~/wa(nted) [Spieler] [Anzahl] [Grund]", Alias = "wa", GreedyArg = true)] diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index f03b95ea..1643b7ac 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -510,21 +510,7 @@ namespace ReallifeGamemode.Server.Events } if (nearestCuffPlayer != null) { - nearestCuffPlayer.SetInFrontOf(player); - nearestCuffPlayer.Heading = player.Heading; - - if (!nearestCuffPlayer.HasAnimation("Cuffed")) - { - player.SyncAnimation("doArrest"); - nearestCuffPlayer.SyncAnimation(new List() { "getArrest", "Cuffed" }); - player.AddAttachment("handcuffs", false); - } - else - { - player.AddAttachment("handcuffs", true); - player.SyncAnimation("doUncuff"); - nearestCuffPlayer.SyncAnimation("getUncuff"); - } + player.CuffPlayer(nearestCuffPlayer); } } if (nearestElevatorPoint != null) diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 4ea122fd..f6d06d3a 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -8,6 +8,7 @@ using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Types; +using ReallifeGamemode.Server.Util; /** * @overview Life of German Reallife - Player Extension (PlayerExtension.cs) @@ -322,9 +323,24 @@ namespace ReallifeGamemode.Server.Extensions player.TriggerEvent("SERVER:SetInFrontPosition", entity); } - public static void SetCuffable(this Player player, bool isCuffable) + public static void CuffPlayer(this Player player, Player nearestCuffPlayer) { - player.SetSharedData("Cuffable", isCuffable); + nearestCuffPlayer.SetInFrontOf(player); + nearestCuffPlayer.Heading = player.Heading; + + if (!nearestCuffPlayer.HasAnimation("Cuffed")) + { + player.SyncAnimation("doArrest"); + nearestCuffPlayer.SyncAnimation(new List() { "getArrest", "Cuffed" }); + nearestCuffPlayer.AddAttachment("handcuffs", false); + nearestCuffPlayer.RemoveAllWeapons(); + } + else + { + nearestCuffPlayer.AddAttachment("handcuffs", true); + player.SyncAnimation("doUncuff"); + nearestCuffPlayer.SyncAnimation("getUncuff"); + } } } }