From 1feb7ba599b4b7f5b7bf97a672f743fe9e730cce Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 30 Aug 2021 20:16:34 +0100 Subject: [PATCH] fix: key binds not registering until resource restart There were a number of people with issues regarding their key binds not getting registered until the resource was restarted. This appears to have been caused by QBus interfering with the `playerSpawned` event which the resource relied on to register the key binds. The exact qb resource in question is unknown presently. --- cl_radar.lua | 46 +++++++++++++--------------------------------- fxmanifest.lua | 2 +- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/cl_radar.lua b/cl_radar.lua index 4c6bdfe..43c37fa 100644 --- a/cl_radar.lua +++ b/cl_radar.lua @@ -41,7 +41,7 @@ local pairs = pairs --[[---------------------------------------------------------------------------------- - Key bind registering + UI loading and key binds registering ----------------------------------------------------------------------------------]]-- local function RegisterKeyBinds() if ( UTIL:IsResourceNameValid() ) then @@ -115,12 +115,6 @@ local function RegisterKeyBinds() end end - ---[[---------------------------------------------------------------------------------- - UI loading and key binds trigger -----------------------------------------------------------------------------------]]-- -local spawned = false - local function LoadUISettings() UTIL:Log( "Attempting to load saved UI settings data." ) @@ -140,32 +134,6 @@ local function LoadUISettings() end end --- Runs every time the player spawns, but the additional check means it only runs the first time --- the player spawns -AddEventHandler( "playerSpawned", function() - if ( not spawned ) then - RegisterKeyBinds() - LoadUISettings() - - spawned = true - end -end ) - --- Loads the UI settings when the resource gets restarted, this way active users don't have the --- default settings applied -AddEventHandler( "onResourceStart", function( resourceName ) - if ( GetCurrentResourceName() == resourceName ) then - Citizen.CreateThread( function() - Citizen.Wait( 1000 ) - - RegisterKeyBinds() - LoadUISettings() - - DecorSetBool( PlayerPedId(), "wk_wars2x_sync_remoteOpen", false ) - end ) - end -end ) - --[[---------------------------------------------------------------------------------- Radar variables @@ -1819,6 +1787,18 @@ Citizen.CreateThread( function() RADAR:CreateFastLimitConfig() end + -- Register the key binds + RegisterKeyBinds() + + -- Wait a short period of time + Citizen.Wait( 1000 ) + + -- Load the saved UI settings (if available) + LoadUISettings() + + -- Set the player's remoteOpen decorator to false + DecorSetBool( PlayerPedId(), "wk_wars2x_sync_remoteOpen", false ) + -- Update the operator menu positions RADAR:UpdateOptionIndexes( true ) diff --git a/fxmanifest.lua b/fxmanifest.lua index 6ede8a1..b34da14 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -38,7 +38,7 @@ game "gta5" name "Wraith ARS 2X" description "Police radar and plate reader system for FiveM" author "WolfKnight" -version "1.3.0" +version "1.3.1" -- Include the files files {