Всем привет, ещё раз, скачал скрипт на залом
Залом человека в наручники как на Majestic RP Rage:MP
Но долго не могу пофиксить точто, при выходи одного из игроков, кто заламывает и кто в заломе, у 2 человека появляется ошибка, и он остается в анимации залома, долго пытался, много пробовал, Понятно что нужно добавить проверку есть ли игрок, существует ли он и убирать анимацию если его нету, у самого не получилось вот полный код, кто может помогите
Залом человека в наручники как на Majestic RP Rage:MP
Но долго не могу пофиксить точто, при выходи одного из игроков, кто заламывает и кто в заломе, у 2 человека появляется ошибка, и он остается в анимации залома, долго пытался, много пробовал, Понятно что нужно добавить проверку есть ли игрок, существует ли он и убирать анимацию если его нету, у самого не получилось вот полный код, кто может помогите
const localPlayer = mp.players.local;
const requestAnimDict = animDict => new Promise(async (resolve, reject) => {
if (mp.game.streaming.hasAnimDictLoaded(animDict))
return resolve(true);
mp.game.streaming.requestAnimDict(animDict);
while(!mp.game.streaming.hasAnimDictLoaded(animDict)) {
await mp.game.waitAsync(1);
}
return resolve(true);
});
mp.events.addDataHandler("im.followed", (entity, value, oldValue) => {
if (value != -1 && mp.players.atRemoteId(value) != null) {
let cop = mp.players.atRemoteId(value);
dragTarget(cop, entity);
}
else if (entity.isSuspected) {
if (entity.isAttached())
entity.detach(true, true);
entity.isSuspected = false;
entity.clearTasks();
}
});
mp.events.addDataHandler("follow.suspect", (entity, value, oldValue) => {
if (value != -1 && mp.players.atRemoteId(value) != null) {
let suspect = mp.players.atRemoteId(value);
dragTarget(entity, suspect);
}
else if (entity.isDragging) {
entity.isDragging = false;
entity.clearTasks();
if (entity.intervalChecker)
clearInterval(entity.intervalChecker);
delete entity.intervalChecker;
delete entity.suspect;
}
});
mp.events.add("render", () => {
if (localPlayer.getVariable("im.followed") != null && localPlayer.getVariable("im.followed") != -1) {
mp.game.controls.disableAllControlActions(2);
mp.game.controls.enableControlAction(2, 30, true);
mp.game.controls.enableControlAction(2, 31, true);
mp.game.controls.enableControlAction(2, 32, true);
mp.game.controls.enableControlAction(2, 1, true);
mp.game.controls.enableControlAction(2, 2, true);
}
// if (localPlayer.getVariable("follow.suspect") != null && localPlayer.getVariable("follow.suspect") != -1) {
// if (!localPlayer.isPlayingAnim(dragAnimDict, "static", 3)) {
// localPlayer.taskPlayAnim(dragAnimDict, "static", 8.0, 1.0, -1, 49, 1.0, false, false, false);
// }
// }
});
// mp.events.add("entityStreamIn", (entity) => {
// if (!entity || entity.type != 'player' || entity.handle == 0 || !mp.players.exists(entity)) return;
// let imFollowed = entity.getVariable("im.followed");
// if (imFollowed != null && imFollowed != -1) {
// let cop = mp.players.atRemoteId(imFollowed);
// if (!cop) return;
// dragTarget(cop, entity);
// return;
// }
// let followSuspect = entity.getVariable("follow.suspect");
// if (followSuspect != null && followSuspect != -1) {
// let suspect = mp.players.atRemoteId(followSuspect);
// if (!suspect) return;
// dragTarget(entity, suspect);
// return;
// }
// });
const cuffAnimDict = "mp_arresting";
async function cuffTarget(cop, target) {
if (!target || !cop || !target.handle || !cop.handle || !mp.players.exists(cop) || !mp.players.exists(target)) return;
await requestAnimDict(cuffAnimDict);
target.clearTasks();
target.taskPlayAnim(cuffAnimDict, "idle", 8.0, 1.0, -1, 49, 1.0, false, false, false);
}
const dragAnimDict = "amb@code_human_wander_drinking_fat@female@base";
async function dragTarget(cop, target) {
if (!target || !cop || !target.handle || !cop.handle || !mp.players.exists(cop) || !mp.players.exists(target) || target.isAttachedTo(cop.handle)) return;
// await cuffTarget(cop, target);
// await requestAnimDict(dragAnimDict);
// cop.taskPlayAnim(dragAnimDict, "static", 8.0, 1.0, -1, 49, 1.0, false, false, false);
cop.isDragging = true;
// target.attachTo(cop.handle, 10000, .7, 0.4, 0, 0.0, 0.0, 0.0, false, false, false, false, 2, true);
target.isSuspected = true;
cop.suspect = target;
cop.intervalChecker = setInterval(() => {
if (cop && cop.suspect) {
// if (cop.isWalking() || cop.isRunning() || cop.isSprinting()) {
// const gotooPosition = cop.suspect.getOffsetFromInWorldCoords(0, 3, 1.32);
// const speed = cop.isSprinting() || cop.isRunning() ? 5 : 1;
// cop.suspect.taskGoStraightToCoord(gotooPosition.x, gotooPosition.y, gotooPosition.z, speed, 500, 130, 1.0);
// cop.suspect._walking = true;
// }
// else if (cop.suspect._walking) {
// var gotooPosition = cop.suspect.getOffsetFromInWorldCoords(0, 0, 1.32)
// cop.suspect.taskGoStraightToCoord(gotooPosition.x, gotooPosition.y, gotooPosition.z, 1, 2000, cop.suspect.getHeading(), 3.0);
// cop.suspect._walking = false;
// }
// mp.game.invoke("0x971D38760FBC02EF", cop.suspect.handle, true);
const e = cop
const t = cop.suspect
mp.game.streaming.hasAnimDictLoaded("majestic_animations_custom") || mp.game.streaming.requestAnimDict("majestic_animations_custom"),
e.isPlayingAnim("majestic_animations_custom", "arrest_owner", 3) || e.taskPlayAnim("majestic_animations_custom", "arrest_owner", 8, -8, -1, 49, 0, !1, !1, !1);
t.isPlayingAnim("majestic_animations_custom", "arrest_follower", 3) || t.taskPlayAnim("majestic_animations_custom", "arrest_follower", 8, -8, -1, 49, 0, !1, !1, !1);
t.attachTo(e.handle, 10000, 0.0, 0.6, 0, 0.0, 0.0, 0.0, true, false, false, false, 2, true);
const o = mp.game.entity.getBoneRotation(e.handle, 91);
t.setHeading(o.z - 90), e.setIkTarget(4, t.handle, 24818, 0, -.12, -.1, 0, -1, -1),
e.setIkTarget(3, t.handle, 61007, -.1, -.06, -.075, 0, 200, -1);
const a = mp.game.object.getOffsetFromCoords(e.position.x, e.position.y, e.position.z, e.getPhysicsHeading(), 0, 3, 0);
mp.game.invoke("0x8339643499D1222E", t.handle, 0, 0, 0), e.isWalking() ? t.taskGoStraightToCoord(a.x, a.y, a.z, 1.2, -1, e.getHeading(), 0) : t.taskStandStill(1);
if (e == localplayer || t == localplayer) {
const n = mp.game.controls;
n.disableControlAction(0, 21, !0), n.disableControlAction(0, 24, !0),
n.disableControlAction(0, 25, !0), n.disableControlAction(0, 69, !0),
n.disableControlAction(0, 75, !0), n.disableControlAction(0, 92, !0),
n.disableControlAction(0, 114, !0), n.disableControlAction(0, 140, !0),
n.disableControlAction(0, 141, !0), n.disableControlAction(0, 142, !0),
n.disableControlAction(0, 257, !0), n.disableControlAction(0, 263, !0),
n.disableControlAction(0, 264, !0), n.disableControlAction(0, 75, !0)
}
}
else {
if (cop.intervalChecker != undefined) {
clearInterval(cop.intervalChecker);
delete cop.intervalChecker;
}
delete cop.suspect;
}
// if (cop && cop.handle && cop.suspect && cop.suspect.handle)
// mp.game.invoke("0xC32779C16FCEECD9", cop.handle, 4, cop.suspect.handle, 45509, 0.18, 0.0, 0.1, 4, 50, 50);
}, 1);
}