From 3d9ae2602c2c5ecf147eaff873dd1d1ef5a31436 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 26 Feb 2021 20:49:15 +0000 Subject: [PATCH] refactor: making sync functions are streamlined a bit --- cl_sync.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cl_sync.lua b/cl_sync.lua index 833e799..a5078d1 100644 --- a/cl_sync.lua +++ b/cl_sync.lua @@ -36,16 +36,21 @@ SYNC = {} --[[---------------------------------------------------------------------------------- Sync functions ----------------------------------------------------------------------------------]]-- -function SYNC:SendPowerState( state ) +function SYNC:SyncData( cb ) local otherPed = PLY:GetOtherPed() if ( otherPed ~= nil and otherPed ~= 0 ) then local otherPly = GetPlayerServerId( NetworkGetPlayerIndexFromPed( otherPed ) ) - TriggerServerEvent( "wk_wars2x_sync:sendPowerState", otherPly, state ) + cb( otherPly ) end end +function SYNC:SendPowerState( state ) + self:SyncData( function( ply ) + TriggerServerEvent( "wk_wars2x_sync:sendPowerState", ply, state ) + end ) +end --[[---------------------------------------------------------------------------------- Sync client events