mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 00:16:27 +02:00
feat: add passenger control for operator menu
This commit is contained in:
10
cl_radar.lua
10
cl_radar.lua
@@ -731,8 +731,10 @@ end
|
||||
|
||||
-- Updates the operator menu option indexes, as the default menu values can be changed in the config, we
|
||||
-- need to update the indexes otherwise the menu will display the wrong values
|
||||
function RADAR:UpdateOptionIndexes()
|
||||
self:LoadOMData()
|
||||
function RADAR:UpdateOptionIndexes( loadSaved )
|
||||
if ( loadSaved ) then
|
||||
self:LoadOMData()
|
||||
end
|
||||
|
||||
-- Iterate through each of the internal settings
|
||||
for k, v in pairs( self.vars.settings ) do
|
||||
@@ -1650,7 +1652,7 @@ end )
|
||||
RegisterNUICallback( "menu", function( data, cb )
|
||||
if ( PLY:CanControlRadar() ) then
|
||||
-- Only run the codw if the radar has power and is not powering up
|
||||
if ( RADAR:IsPowerOn() and not RADAR:IsPoweringUp() and PLY:IsDriver() ) then
|
||||
if ( RADAR:IsPowerOn() and not RADAR:IsPoweringUp() ) then
|
||||
-- As the menu button is a multipurpose button, we first check to see if the menu is already open
|
||||
if ( RADAR:IsMenuOpen() ) then
|
||||
-- As the menu is already open, we then iterate to the next option in the settings list
|
||||
@@ -1875,7 +1877,7 @@ Citizen.CreateThread( function()
|
||||
RADAR:UpdateRayEndCoords()
|
||||
|
||||
-- Update the operator menu positions
|
||||
RADAR:UpdateOptionIndexes()
|
||||
RADAR:UpdateOptionIndexes( true )
|
||||
|
||||
-- If the fast limit feature is allowed, create the config in the radar variables
|
||||
if ( RADAR:IsFastLimitAllowed() ) then
|
||||
|
||||
@@ -141,6 +141,7 @@ end
|
||||
function RADAR:SetOMTableData( data )
|
||||
if ( type( data ) == "table" ) then
|
||||
self.vars.settings = data
|
||||
self:UpdateOptionIndexes( false )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -433,7 +434,7 @@ end )
|
||||
-- Event for receiving updated operator menu data from another player
|
||||
RegisterNetEvent( "wk_wars2x_sync:receiveUpdatedOMData" )
|
||||
AddEventHandler( "wk_wars2x_sync:receiveUpdatedOMData", function( data )
|
||||
if ( PLY:IsPassenger() and RADAR:IsThereBackupData() ) then
|
||||
if ( PLY:IsDriver() or ( PLY:IsPassenger() and RADAR:IsThereBackupData() ) ) then
|
||||
RADAR:SetOMTableData( data )
|
||||
RADAR:SendSettingUpdate()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user