refactor: making sync functions are streamlined a bit

This commit is contained in:
Dan
2021-02-26 20:49:15 +00:00
parent 695ff71577
commit 3d9ae2602c

View File

@@ -36,16 +36,21 @@ SYNC = {}
--[[---------------------------------------------------------------------------------- --[[----------------------------------------------------------------------------------
Sync functions Sync functions
----------------------------------------------------------------------------------]]-- ----------------------------------------------------------------------------------]]--
function SYNC:SendPowerState( state ) function SYNC:SyncData( cb )
local otherPed = PLY:GetOtherPed() local otherPed = PLY:GetOtherPed()
if ( otherPed ~= nil and otherPed ~= 0 ) then if ( otherPed ~= nil and otherPed ~= 0 ) then
local otherPly = GetPlayerServerId( NetworkGetPlayerIndexFromPed( otherPed ) ) local otherPly = GetPlayerServerId( NetworkGetPlayerIndexFromPed( otherPed ) )
TriggerServerEvent( "wk_wars2x_sync:sendPowerState", otherPly, state ) cb( otherPly )
end end
end end
function SYNC:SendPowerState( state )
self:SyncData( function( ply )
TriggerServerEvent( "wk_wars2x_sync:sendPowerState", ply, state )
end )
end
--[[---------------------------------------------------------------------------------- --[[----------------------------------------------------------------------------------
Sync client events Sync client events