Решил написать систему быстрых анимаций.
Проблема в том, что оно не открываеться (делал на сборке редаги)
Добавил в src_cef и прописал
Теперь добавил в src_client/player/bind.js
Потом добавил файл и подключил его xAnimations.js
Если сможете помочь буду благодарен!
Проблема в том, что оно не открываеться (делал на сборке редаги)
Добавил в src_cef и прописал
Код:
index.svelte
<script>
import { translateText } from 'lang'
import { storeAnimBind } from 'store/animation'
import { executeClient } from 'api/rage'
export let viewData = false;
const playAnimation = (animId) => {
if (animId && animId !== 0) {
executeClient("client.animation.play", animId);
closeMenu();
}
};
const stopAnimation = () => {
executeClient("client.animation.stop");
closeMenu();
};
const closeMenu = () => {
executeClient("escape");
};
</script>
{#if viewData}
<div style="position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.8); z-index: 9999; display: flex; align-items: center; justify-content: center;">
<div style="background: #333; color: white; padding: 30px; border-radius: 10px; text-align: center;">
<h2>Быстрые анимации</h2>
<div style="margin: 20px 0;">
{#each $storeAnimBind as animId, index}
{@const keyNumber = index === 9 ? '0' : (index + 1).toString()}
<div style="margin: 10px; padding: 10px; background: #555; border-radius: 5px; cursor: pointer;" on:click={() => playAnimation(animId)}>
<strong>{keyNumber}:</strong>
{#if animId && animId !== 0}
Анимация {animId}
{:else}
Пусто
{/if}
</div>
{/each}
</div>
<div style="margin: 20px 0;">
<button style="padding: 10px 20px; background: #e74c3c; color: white; border: none; border-radius: 5px; cursor: pointer;" on:click={stopAnimation}>
ОСТАНОВИТЬ АНИМАЦИЮ
</button>
</div>
<div style="margin: 20px 0;">
<button style="padding: 10px 20px; background: #666; color: white; border: none; border-radius: 5px; cursor: pointer;" on:click={closeMenu}>
ЗАКРЫТЬ (ESC)
</button>
</div>
</div>
</div>
{/if}
Теперь добавил в src_client/player/bind.js
Код:
{//64
title: translateText("Быстрые анимации"),
keyCode: global.Keys.VK_X,
keyCodeDefault: global.Keys.VK_X,
function: "o_xAnimations",
type: binderType.onFoot,
group: binderGroup.user,
menu: menuType.all//+
}
Потом добавил файл и подключил его xAnimations.js
Код:
let xAnimationsToggled = false;
global.binderFunctions.o_xAnimations = (isCef = false) => {
console.log('o_xAnimations вызвана, isCef:', isCef);
if (!isCef) return;
if (!global.loggedin ||
global.chatActive ||
global.editing ||
global.cuffed ||
global.menuCheck() ||
global.isDeath === true ||
global.isDemorgan ||
global.localplayer.isInAnyVehicle(false)) {
console.log('Условия не выполнены для открытия X-меню');
return;
}
console.log('Открываем X-меню анимаций');
mp.gui.emmit(`window.router.setView('XAnimations', true);`);
global.menuOpen(true);
xAnimationsToggled = true;
};
global.binderFunctions.c_xAnimations = async () => {
if (!xAnimationsToggled) return;
mp.gui.emmit(`window.router.setHud();`);
xAnimationsToggled = false;
await global.wait(50);
global.menuClose();
};
global.binderFunctions.fastAnim_1 = () => {
if (!global.loggedin ||
global.chatActive ||
global.menuCheck() ||
global.isDemorgan == true ||
global.attachedtotrunk ||
global.localplayer.isInAnyVehicle(false)) return;
if (!global.antiFlood("fastAnim", 1000)) return;
mp.gui.emmit(`window.animationStore.playFastAnimation(0);`);
global.lastCheck = new Date().getTime();
};
global.binderFunctions.fastAnim_2 = () => {
if (!global.loggedin ||
global.chatActive ||
global.menuCheck() ||
global.isDemorgan == true ||
global.attachedtotrunk ||
global.localplayer.isInAnyVehicle(false)) return;
if (!global.antiFlood("fastAnim", 1000)) return;
mp.gui.emmit(`window.animationStore.playFastAnimation(1);`);
global.lastCheck = new Date().getTime();
};
global.binderFunctions.fastAnim_3 = () => {
if (!global.loggedin ||
global.chatActive ||
global.menuCheck() ||
global.isDemorgan == true ||
global.attachedtotrunk ||
global.localplayer.isInAnyVehicle(false)) return;
if (!global.antiFlood("fastAnim", 1000)) return;
mp.gui.emmit(`window.animationStore.playFastAnimation(2);`);
global.lastCheck = new Date().getTime();
};
global.binderFunctions.fastAnim_4 = () => {
if (!global.loggedin ||
global.chatActive ||
global.menuCheck() ||
global.isDemorgan == true ||
global.attachedtotrunk ||
global.localplayer.isInAnyVehicle(false)) return;
if (!global.antiFlood("fastAnim", 1000)) return;
mp.gui.emmit(`window.animationStore.playFastAnimation(3);`);
global.lastCheck = new Date().getTime();
};
global.binderFunctions.fastAnim_5 = () => {
if (!global.loggedin ||
global.chatActive ||
global.menuCheck() ||
global.isDemorgan == true ||
global.attachedtotrunk ||
global.localplayer.isInAnyVehicle(false)) return;
if (!global.antiFlood("fastAnim", 1000)) return;
mp.gui.emmit(`window.animationStore.playFastAnimation(4);`);
global.lastCheck = new Date().getTime();
};
global.binderFunctions.fastAnim_6 = () => {
if (!global.loggedin ||
global.chatActive ||
global.menuCheck() ||
global.isDemorgan == true ||
global.attachedtotrunk ||
global.localplayer.isInAnyVehicle(false)) return;
if (!global.antiFlood("fastAnim", 1000)) return;
mp.gui.emmit(`window.animationStore.playFastAnimation(5);`);
global.lastCheck = new Date().getTime();
};
global.binderFunctions.fastAnim_7 = () => {
if (!global.loggedin ||
global.chatActive ||
global.menuCheck() ||
global.isDemorgan == true ||
global.attachedtotrunk ||
global.localplayer.isInAnyVehicle(false)) return;
if (!global.antiFlood("fastAnim", 1000)) return;
mp.gui.emmit(`window.animationStore.playFastAnimation(6);`);
global.lastCheck = new Date().getTime();
};
global.binderFunctions.fastAnim_8 = () => {
if (!global.loggedin ||
global.chatActive ||
global.menuCheck() ||
global.isDemorgan == true ||
global.attachedtotrunk ||
global.localplayer.isInAnyVehicle(false)) return;
if (!global.antiFlood("fastAnim", 1000)) return;
mp.gui.emmit(`window.animationStore.playFastAnimation(7);`);
global.lastCheck = new Date().getTime();
};
global.binderFunctions.fastAnim_9 = () => {
if (!global.loggedin ||
global.chatActive ||
global.menuCheck() ||
global.isDemorgan == true ||
global.attachedtotrunk ||
global.localplayer.isInAnyVehicle(false)) return;
if (!global.antiFlood("fastAnim", 1000)) return;
mp.gui.emmit(`window.animationStore.playFastAnimation(8);`);
global.lastCheck = new Date().getTime();
};
global.binderFunctions.fastAnim_0 = () => {
if (!global.loggedin ||
global.chatActive ||
global.menuCheck() ||
global.isDemorgan == true ||
global.attachedtotrunk ||
global.localplayer.isInAnyVehicle(false)) return;
if (!global.antiFlood("fastAnim", 1000)) return;
mp.gui.emmit(`window.animationStore.playFastAnimation(9);`);
global.lastCheck = new Date().getTime();
};
gm.events.add('client.xAnimations.open', () => {
global.binderFunctions.o_xAnimations(true);
});
gm.events.add('client.xAnimations.open', () => {
global.binderFunctions.o_xAnimations(true);
gm.discord("Открывает быстрые анимации");
});
gm.events.add('client.xAnimations.close', () => {
global.binderFunctions.c_xAnimations();
});
gm.events.add('client.xAnimations.playFastAnimation', (slotIndex) => {
try {
if (!global.loggedin ||
global.chatActive ||
global.editing ||
global.cuffed ||
global.isDeath === true ||
global.isDemorgan ||
global.startedMining === true ||
global.startedMafiaGame ||
global.localplayer.isInAnyVehicle(false)) return;
mp.gui.emmit(`window.animationStore.playAnimationFromSlot(${slotIndex});`);
} catch (e) {
mp.events.callRemote("client_trycatch", "player/xAnimations", "client.xAnimations.playFastAnimation", e.toString());
}
});
Если сможете помочь буду благодарен!