From e13f716b97f444f694eb5aba754c8d6eef483563 Mon Sep 17 00:00:00 2001 From: Andre Tabarra Date: Mon, 31 May 2021 08:05:52 -0300 Subject: [PATCH] feat: disable menu on convar --- scripts/menu/client/cl_menu.lua | 88 +++++++++++++++++++-------------- scripts/menu/server/sv_menu.lua | 8 ++- web/settings.html | 2 +- 3 files changed, 60 insertions(+), 38 deletions(-) diff --git a/scripts/menu/client/cl_menu.lua b/scripts/menu/client/cl_menu.lua index a21e71cba..656cd366f 100644 --- a/scripts/menu/client/cl_menu.lua +++ b/scripts/menu/client/cl_menu.lua @@ -12,13 +12,14 @@ CreateThread(function() isMenuDebug = (GetConvar('TXADMIN_MENU_DEBUG', 'false') == 'true') end) --- Since the menu yields/receives keyboard --- focus we need to store that the menu is already visible -local isMenuVisible --- Last location stored in a vec3 -local lastTp -RegisterKeyMapping('txadmin', 'Open the txAdmin Menu', 'keyboard', '') + + + +local isRDR = not TerraingridActivate and true or false +local dismissKey = isRDR and 0xD9D0E1C0 or 22 +local dismissKeyGroup = isRDR and 1 or 0 + --- Send data to the NUI frame ---@param action string Action @@ -30,6 +31,50 @@ function sendMenuMessage(action, data) }) end +local function openWarningHandler(author, reason) + sendMenuMessage('setWarnOpen', { + reason = reason, + warnedBy = author + }) + + CreateThread(function() + local countLimit = 100 --10 seconds + local count = 0 + while true do + Wait(100) + if IsControlPressed(dismissKeyGroup, dismissKey) then + count = count +1 + if count >= countLimit then + sendMenuMessage('closeWarning') + return + elseif math.fmod(count, 10) == 0 then + sendMenuMessage('pulseWarning') + end + else + count = 0 + end + end + end) +end + +RegisterNetEvent('txAdminClient:warn', openWarningHandler) + + +--BETA BETA BETA BETA BETA BETA BETA BETA BETA BETA BETA +if (GetConvar('txEnableMenuBeta', 'false') ~= 'true') then + print('txAdmin beta menu disabled.') + return +end + + +-- Since the menu yields/receives keyboard +-- focus we need to store that the menu is already visible +local isMenuVisible +-- Last location stored in a vec3 +local lastTp + +RegisterKeyMapping('txadmin', 'Open the txAdmin Menu', 'keyboard', '') + --- Will update ServerCtx based on GlobalState and will send it to NUI local function updateServerCtx() local ServerCtx = GlobalState.txAdminServerCtx @@ -545,35 +590,6 @@ RegisterNetEvent('txAdmin:menu:spawnVehicle', function(netID) end end) -local isRDR = not TerraingridActivate and true or false -local dismissKey = isRDR and 0xD9D0E1C0 or 22 -local dismissKeyGroup = isRDR and 1 or 0 - -local function openWarningHandler(author, reason) - sendMenuMessage('setWarnOpen', { - reason = reason, - warnedBy = author - }) - - CreateThread(function() - local countLimit = 100 --10 seconds - local count = 0 - while true do - Wait(100) - if IsControlPressed(dismissKeyGroup, dismissKey) then - count = count +1 - if count >= countLimit then - sendMenuMessage('closeWarning') - return - elseif math.fmod(count, 10) == 0 then - sendMenuMessage('pulseWarning') - end - else - count = 0 - end - end - end) -end CreateThread(function() while true do @@ -584,4 +600,4 @@ CreateThread(function() end end) -RegisterNetEvent('txAdminClient:warn', openWarningHandler) + diff --git a/scripts/menu/server/sv_menu.lua b/scripts/menu/server/sv_menu.lua index d9c68c34c..ae8ba86ab 100644 --- a/scripts/menu/server/sv_menu.lua +++ b/scripts/menu/server/sv_menu.lua @@ -5,7 +5,7 @@ end local apiHost = GetConvar("txAdmin-apiHost", "invalid") local pipeToken = GetConvar("txAdmin-pipeToken", "invalid") if apiHost == "invalid" or pipeToken == "invalid" then - logError('API Host or Pipe Token ConVars not found. Do not start this resource if not using txAdmin.') + print('API Host or Pipe Token ConVars not found. Do not start this resource if not using txAdmin.') return end @@ -14,6 +14,12 @@ if (GetConvar('TXADMIN_MENU_DEBUG', 'false') ~= 'true') then SetConvar("txAdmin-pipeToken", "removed") end +--BETA BETA BETA BETA BETA BETA BETA BETA BETA BETA BETA +if (GetConvar('txEnableMenuBeta', 'false') ~= 'true') then + print('txAdmin beta menu disabled.') + return +end + -- Vars local adminPermissions = {} diff --git a/web/settings.html b/web/settings.html index cc102d20a..73feb9265 100644 --- a/web/settings.html +++ b/web/settings.html @@ -146,7 +146,7 @@

Settings

- To enable the Beta In-game, add +set txEnableMenuBeta true above. + To enable the Beta In-game, add +setr txEnableMenuBeta true above. Additional command-line arguments to pass to the FXServer instance.