From 33b711d53b35bc781c4a59eb6e323cd6a2bb8d8a Mon Sep 17 00:00:00 2001 From: ivanzaida Date: Fri, 23 Aug 2024 20:31:09 +0300 Subject: [PATCH] fix: make ui focused while runcode is open --- code/client/src/index.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/code/client/src/index.ts b/code/client/src/index.ts index 88ca6ca..008a405 100644 --- a/code/client/src/index.ts +++ b/code/client/src/index.ts @@ -6,24 +6,15 @@ const commandName = 'toggleEditor'; const noop = (): void => null; -let tick = null; const openEditor = (): void => { - SetNuiFocus(true, true); - SetNuiFocusKeepInput(true); - SetPlayerControl(PlayerId(), false, 0); emitNUI('editor:isOpen', true); - tick = setTick(() => { - DisableAllControlActions(0); - }); + SetNuiFocus(true, true); }; const closeEditor = (): void => { - SetNuiFocus(false, false); - SetPlayerControl(PlayerId(), true, 0); emitNUI('editor:isOpen', false); - clearTick(tick); - tick = undefined; + SetNuiFocus(false, false); }; let isOpen = false; @@ -45,6 +36,7 @@ onNUI('bcl-runcode:close', () => { onNUI('bcl-runcode::run::js::server', (...args: unknown[]) => emitNet('bcl-code:runCode::js::server', ...args)); const gameName = GetGameName(); + if (gameName === 'fivem') { RegisterCommand('+' + commandName, noop, false); RegisterCommand('-' + commandName, toggleEditor, false);