mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 00:16:27 +02:00
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.
This commit is contained in:
46
cl_radar.lua
46
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 )
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user