From 338f3bb24319acf3c761320f70296bcdc85a0a23 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 19 Mar 2021 14:08:23 +0000 Subject: [PATCH] feat(sync): only trigger sync on enter if passenger view allowed --- cl_player.lua | 2 +- cl_sync.lua | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/cl_player.lua b/cl_player.lua index 330c27b..5d0ba4a 100644 --- a/cl_player.lua +++ b/cl_player.lua @@ -111,7 +111,7 @@ end ) Citizen.CreateThread( function() while ( true ) do -- The sync trigger should only start when the player is getting into a vehicle - if ( IsPedGettingIntoAVehicle( PLY.ped ) ) then + if ( IsPedGettingIntoAVehicle( PLY.ped ) and RADAR:IsPassengerViewAllowed() ) then -- Get the vehicle the player is entering local vehEntering = GetVehiclePedIsEntering( PLY.ped ) diff --git a/cl_sync.lua b/cl_sync.lua index 4541dfd..e7045cb 100644 --- a/cl_sync.lua +++ b/cl_sync.lua @@ -349,20 +349,18 @@ function SYNC:SyncDataOnEnter() -- Make sure passenger view is allowed, also, using PLY:IsPassenger() already checks that the player's -- vehicle meets the requirements of what the radar requires. This way we don't have to do additional -- checks manually. - if ( RADAR:IsPassengerViewAllowed() ) then - if ( PLY:IsPassenger() ) then - local driver = PLY:GetOtherPedServerId() + if ( PLY:IsPassenger() ) then + local driver = PLY:GetOtherPedServerId() - -- Only trigger the event if there is actually a driver - if ( driver ~= nil ) then - TriggerServerEvent( "wk_wars2x_sync:requestRadarData", driver ) - end - elseif ( PLY:IsDriver() ) then - if ( RADAR:IsThereBackupData() ) then - -- Restore the local data - RADAR:RestoreFromBackup() - READER:RestoreFromBackup() - end + -- Only trigger the event if there is actually a driver + if ( driver ~= nil ) then + TriggerServerEvent( "wk_wars2x_sync:requestRadarData", driver ) + end + elseif ( PLY:IsDriver() ) then + if ( RADAR:IsThereBackupData() ) then + -- Restore the local data + RADAR:RestoreFromBackup() + READER:RestoreFromBackup() end end end