diff --git a/cl_radar.lua b/cl_radar.lua index 5369c80..d8852d9 100644 --- a/cl_radar.lua +++ b/cl_radar.lua @@ -335,6 +335,10 @@ function RADAR:GetRadarDataForSync() } end +function RADAR:GetOMTableData() + return self.vars.settings +end + -- Sets the operator menu settings table within the radar's main variables table function RADAR:SetOMTableData( data ) if ( type( data ) == "table" ) then @@ -772,6 +776,12 @@ function RADAR:CloseMenu( playAudio ) -- Save the operator menu values local omData = json.encode( RADAR.vars.settings ) SetResourceKvp( "wk_wars2x_om_data", omData ) + + -- Send the operator menu to the passenger if allowed + if ( self:IsPassengerViewAllowed() ) then + local updatedOMData = self:GetOMTableData() + SYNC:SendUpdatedOMData( updatedOMData ) + end end -- Returns if the operator menu is open diff --git a/cl_sync.lua b/cl_sync.lua index f8d24a4..10297d7 100644 --- a/cl_sync.lua +++ b/cl_sync.lua @@ -90,6 +90,12 @@ function SYNC:LockAntennaSpeed( ant, data ) end ) end +function SYNC:SendUpdatedOMData( data ) + self:SyncData( function( ply ) + TriggerServerEvent( "wk_wars2x_sync:sendUpdatedOMData", ply, data ) + end ) +end + -- Requests radar data from the driver if the player has just entered a valid vehicle as a front seat passenger function SYNC:SyncDataOnEnter() -- Make sure passenger view is allowed, also, using PLY:IsPassenger() already checks that the player's @@ -167,4 +173,12 @@ end ) RegisterNetEvent( "wk_wars2x_sync:receiveRadarData" ) AddEventHandler( "wk_wars2x_sync:receiveRadarData", function( data ) RADAR:LoadDataFromDriver( data ) +end ) + +RegisterNetEvent( "wk_wars2x_sync:receiveUpdatedOMData" ) +AddEventHandler( "wk_wars2x_sync:receiveUpdatedOMData", function( data ) + if ( PLY:IsPassenger() and RADAR:IsThereBackupData() ) then + RADAR:SetOMTableData( data ) + RADAR:SendSettingUpdate() + end end ) \ No newline at end of file diff --git a/sv_sync.lua b/sv_sync.lua index 833922e..c61bc32 100644 --- a/sv_sync.lua +++ b/sv_sync.lua @@ -71,4 +71,9 @@ end ) RegisterNetEvent( "wk_wars2x_sync:sendRadarDataForPassenger" ) AddEventHandler( "wk_wars2x_sync:sendRadarDataForPassenger", function( playerFor, data ) TriggerClientEvent( "wk_wars2x_sync:receiveRadarData", playerFor, data ) +end ) + +RegisterNetEvent( "wk_wars2x_sync:sendUpdatedOMData" ) +AddEventHandler( "wk_wars2x_sync:sendUpdatedOMData", function( playerFor, data ) + TriggerClientEvent( "wk_wars2x_sync:receiveUpdatedOMData", playerFor, data ) end ) \ No newline at end of file