Skip to content

Commit

Permalink
docs: add comments to cl_sync.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfKnight98 committed Mar 14, 2021
1 parent dc8a9a7 commit 7701cce
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions cl_sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ SYNC = {}
--[[----------------------------------------------------------------------------------
Sync functions
----------------------------------------------------------------------------------]]--
-- Returns if the given player has the remote open
function SYNC:IsRemoteAlreadyOpen( ply )
return DecorGetBool( ply, "wk_wars2x_sync_remoteOpen" )
end

-- Sets the remote open decor for the local player to the given state
function SYNC:SetRemoteOpenState( state )
DecorSetBool( PLY.ped, "wk_wars2x_sync_remoteOpen", state )
end
Expand Down Expand Up @@ -90,6 +92,7 @@ function SYNC:LockAntennaSpeed( ant, data )
end )
end

-- Sends the given operator menu table data to the other player
function SYNC:SendUpdatedOMData( data )
self:SyncData( function( ply )
TriggerServerEvent( "wk_wars2x_sync:sendUpdatedOMData", ply, data )
Expand All @@ -103,16 +106,13 @@ function SYNC:SyncDataOnEnter()
-- checks manually.
if ( RADAR:IsPassengerViewAllowed() ) then
if ( PLY:IsPassenger() ) then
-- UTIL:Notify( "Triggering server event to get radar data" )
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
-- UTIL:Notify( "Restoring local radar data" )

if ( RADAR:IsThereBackupData() ) then
-- Restore the local data
RADAR:RestoreFromBackup()
Expand Down Expand Up @@ -156,25 +156,21 @@ AddEventHandler( "wk_wars2x_sync:receiveLockAntennaSpeed", function( antenna, da
RADAR:LockAntennaSpeed( antenna, data, true )
end )




-- Event for gathering the radar data and sending it to another player
RegisterNetEvent( "wk_wars2x_sync:getRadarDataFromDriver" )
AddEventHandler( "wk_wars2x_sync:getRadarDataFromDriver", function( playerFor )
-- print( "Radar table has been requested by " .. tostring( GetPlayerName( playerFor ) ) )

local data = RADAR:GetRadarDataForSync()

-- print( "Got table (type: " .. type( data ) .. ")" )

TriggerServerEvent( "wk_wars2x_sync:sendRadarDataForPassenger", playerFor, data )
end )

-- Event for receiving radar data from another player
RegisterNetEvent( "wk_wars2x_sync:receiveRadarData" )
AddEventHandler( "wk_wars2x_sync:receiveRadarData", function( data )
RADAR:LoadDataFromDriver( data )
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
Expand Down

0 comments on commit 7701cce

Please sign in to comment.