This commit is contained in:
2021-04-07 17:34:18 +02:00
parent 5cea81de72
commit 78f4e136ee
5 changed files with 47 additions and 41 deletions

View File

@@ -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);