Skip to content

Commit

Permalink
feat: add passenger control for operator menu
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfKnight98 committed Mar 15, 2021
1 parent 6f4f5e7 commit 8f0037d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions cl_radar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion cl_sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ end
function RADAR:SetOMTableData( data )
if ( type( data ) == "table" ) then
self.vars.settings = data
self:UpdateOptionIndexes( false )
end
end

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8f0037d

Please sign in to comment.