mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 08:26:27 +02:00
Another attempted fix for the key binds issue
Key binds now get registered only when the player has spawned in, rather than when the code gets run at the bottom of the file.
This commit is contained in:
120
cl_radar.lua
120
cl_radar.lua
@@ -41,7 +41,66 @@ local pairs = pairs
|
|||||||
|
|
||||||
|
|
||||||
--[[----------------------------------------------------------------------------------
|
--[[----------------------------------------------------------------------------------
|
||||||
UI loading trigger
|
Key bind registering
|
||||||
|
----------------------------------------------------------------------------------]]--
|
||||||
|
local function RegisterKeyBinds()
|
||||||
|
-- Opens the remote control
|
||||||
|
RegisterCommand( "radar_remote", function()
|
||||||
|
if ( not RADAR:GetKeyLockState() ) then
|
||||||
|
RADAR:OpenRemote()
|
||||||
|
end
|
||||||
|
end )
|
||||||
|
RegisterKeyMapping( "radar_remote", "Open Remote Control", "keyboard", CONFIG.keyDefaults.remote_control )
|
||||||
|
|
||||||
|
-- Locks speed from front antenna
|
||||||
|
RegisterCommand( "radar_fr_ant", function()
|
||||||
|
if ( not RADAR:GetKeyLockState() ) then
|
||||||
|
RADAR:LockAntennaSpeed( "front" )
|
||||||
|
end
|
||||||
|
end )
|
||||||
|
RegisterKeyMapping( "radar_fr_ant", "Front Antenna Lock/Unlock", "keyboard", CONFIG.keyDefaults.front_lock )
|
||||||
|
|
||||||
|
-- Locks speed from rear antenna
|
||||||
|
RegisterCommand( "radar_bk_ant", function()
|
||||||
|
if ( not RADAR:GetKeyLockState() ) then
|
||||||
|
RADAR:LockAntennaSpeed( "rear" )
|
||||||
|
end
|
||||||
|
end )
|
||||||
|
RegisterKeyMapping( "radar_bk_ant", "Rear Antenna Lock/Unlock", "keyboard", CONFIG.keyDefaults.rear_lock )
|
||||||
|
|
||||||
|
-- Locks front plate reader
|
||||||
|
RegisterCommand( "radar_fr_cam", function()
|
||||||
|
if ( not RADAR:GetKeyLockState() ) then
|
||||||
|
READER:LockCam( "front", true, false )
|
||||||
|
end
|
||||||
|
end )
|
||||||
|
RegisterKeyMapping( "radar_fr_cam", "Front Plate Reader Lock/Unlock", "keyboard", CONFIG.keyDefaults.plate_front_lock )
|
||||||
|
|
||||||
|
-- Locks rear plate reader
|
||||||
|
RegisterCommand( "radar_bk_cam", function()
|
||||||
|
if ( not RADAR:GetKeyLockState() ) then
|
||||||
|
READER:LockCam( "rear", true, false )
|
||||||
|
end
|
||||||
|
end )
|
||||||
|
RegisterKeyMapping( "radar_bk_cam", "Rear Plate Reader Lock/Unlock", "keyboard", CONFIG.keyDefaults.plate_rear_lock )
|
||||||
|
|
||||||
|
-- Toggles the key lock state
|
||||||
|
RegisterCommand( "radar_key_lock", function()
|
||||||
|
RADAR:ToggleKeyLock()
|
||||||
|
end )
|
||||||
|
RegisterKeyMapping( "radar_key_lock", "Toggle Keybind Lock", "keyboard", CONFIG.keyDefaults.key_lock )
|
||||||
|
|
||||||
|
-- Deletes all of the KVPs
|
||||||
|
RegisterCommand( "reset_radar_data", function()
|
||||||
|
DeleteResourceKvp( "wk_wars2x_ui_data" )
|
||||||
|
DeleteResourceKvp( "wk_wars2x_om_data" )
|
||||||
|
DeleteResourceKvp( "wk_wars2x_new_user" )
|
||||||
|
end, false )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--[[----------------------------------------------------------------------------------
|
||||||
|
UI loading and key binds trigger
|
||||||
----------------------------------------------------------------------------------]]--
|
----------------------------------------------------------------------------------]]--
|
||||||
local spawned = false
|
local spawned = false
|
||||||
|
|
||||||
@@ -68,6 +127,7 @@ end
|
|||||||
-- the player spawns
|
-- the player spawns
|
||||||
AddEventHandler( "playerSpawned", function()
|
AddEventHandler( "playerSpawned", function()
|
||||||
if ( not spawned ) then
|
if ( not spawned ) then
|
||||||
|
RegisterKeyBinds()
|
||||||
LoadUISettings()
|
LoadUISettings()
|
||||||
|
|
||||||
spawned = true
|
spawned = true
|
||||||
@@ -80,6 +140,7 @@ AddEventHandler( "onResourceStart", function( resourceName )
|
|||||||
if ( GetCurrentResourceName() == resourceName ) then
|
if ( GetCurrentResourceName() == resourceName ) then
|
||||||
Citizen.Wait( 2000 )
|
Citizen.Wait( 2000 )
|
||||||
|
|
||||||
|
RegisterKeyBinds()
|
||||||
LoadUISettings()
|
LoadUISettings()
|
||||||
end
|
end
|
||||||
end )
|
end )
|
||||||
@@ -1814,60 +1875,3 @@ Citizen.CreateThread( function()
|
|||||||
Citizen.Wait( 3000 )
|
Citizen.Wait( 3000 )
|
||||||
end
|
end
|
||||||
end )
|
end )
|
||||||
|
|
||||||
Citizen.CreateThread( function()
|
|
||||||
Citizen.Wait( 3000 )
|
|
||||||
|
|
||||||
-- Opens the remote control
|
|
||||||
RegisterCommand( "radar_remote", function()
|
|
||||||
if ( not RADAR:GetKeyLockState() ) then
|
|
||||||
RADAR:OpenRemote()
|
|
||||||
end
|
|
||||||
end )
|
|
||||||
RegisterKeyMapping( "radar_remote", "Open Remote Control", "keyboard", CONFIG.keyDefaults.remote_control )
|
|
||||||
|
|
||||||
-- Locks speed from front antenna
|
|
||||||
RegisterCommand( "radar_fr_ant", function()
|
|
||||||
if ( not RADAR:GetKeyLockState() ) then
|
|
||||||
RADAR:LockAntennaSpeed( "front" )
|
|
||||||
end
|
|
||||||
end )
|
|
||||||
RegisterKeyMapping( "radar_fr_ant", "Front Antenna Lock/Unlock", "keyboard", CONFIG.keyDefaults.front_lock )
|
|
||||||
|
|
||||||
-- Locks speed from rear antenna
|
|
||||||
RegisterCommand( "radar_bk_ant", function()
|
|
||||||
if ( not RADAR:GetKeyLockState() ) then
|
|
||||||
RADAR:LockAntennaSpeed( "rear" )
|
|
||||||
end
|
|
||||||
end )
|
|
||||||
RegisterKeyMapping( "radar_bk_ant", "Rear Antenna Lock/Unlock", "keyboard", CONFIG.keyDefaults.rear_lock )
|
|
||||||
|
|
||||||
-- Locks front plate reader
|
|
||||||
RegisterCommand( "radar_fr_cam", function()
|
|
||||||
if ( not RADAR:GetKeyLockState() ) then
|
|
||||||
READER:LockCam( "front", true, false )
|
|
||||||
end
|
|
||||||
end )
|
|
||||||
RegisterKeyMapping( "radar_fr_cam", "Front Plate Reader Lock/Unlock", "keyboard", CONFIG.keyDefaults.plate_front_lock )
|
|
||||||
|
|
||||||
-- Locks rear plate reader
|
|
||||||
RegisterCommand( "radar_bk_cam", function()
|
|
||||||
if ( not RADAR:GetKeyLockState() ) then
|
|
||||||
READER:LockCam( "rear", true, false )
|
|
||||||
end
|
|
||||||
end )
|
|
||||||
RegisterKeyMapping( "radar_bk_cam", "Rear Plate Reader Lock/Unlock", "keyboard", CONFIG.keyDefaults.plate_rear_lock )
|
|
||||||
|
|
||||||
-- Toggles the key lock state
|
|
||||||
RegisterCommand( "radar_key_lock", function()
|
|
||||||
RADAR:ToggleKeyLock()
|
|
||||||
end )
|
|
||||||
RegisterKeyMapping( "radar_key_lock", "Toggle Keybind Lock", "keyboard", CONFIG.keyDefaults.key_lock )
|
|
||||||
|
|
||||||
-- Deletes all of the KVPs
|
|
||||||
RegisterCommand( "reset_radar_data", function()
|
|
||||||
DeleteResourceKvp( "wk_wars2x_ui_data" )
|
|
||||||
DeleteResourceKvp( "wk_wars2x_om_data" )
|
|
||||||
DeleteResourceKvp( "wk_wars2x_new_user" )
|
|
||||||
end, false )
|
|
||||||
end )
|
|
||||||
Reference in New Issue
Block a user