Skip to content

Commit

Permalink
Force Sync mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ov-anisa committed Jun 12, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 6e5943d commit c1c9f6e
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions [Library]/assetify_library/exports/shared.lua
Original file line number Diff line number Diff line change
@@ -73,10 +73,10 @@ function getElementAssetInfo(element)
return syncer.syncedElements[element].type, syncer.syncedElements[element].name, syncer.syncedElements[element].clump, syncer.syncedElements[element].clumpMaps
end

function setGlobalData(data, value)
function setGlobalData(data, value, isForceSync)
if imports.type(data) ~= "string" then return false end
syncer.syncedGlobalDatas[data] = value
if not localPlayer then syncer:syncGlobalData(data, value) end
if not localPlayer then syncer:syncGlobalData(data, value, isForceSync) end
return true
end

@@ -85,11 +85,11 @@ function getGlobalData(data)
return syncer.syncedGlobalDatas[data]
end

function setEntityData(element, data, value)
function setEntityData(element, data, value, isForceSync)
if not element or not imports.isElement(element) or not data or (imports.type(data) ~= "string") then return false end
syncer.syncedEntityDatas[element] = syncer.syncedEntityDatas[element] or {}
syncer.syncedEntityDatas[element][data] = value
if not localPlayer then syncer:syncEntityData(element, data, value) end
if not localPlayer then syncer:syncEntityData(element, data, value, isForceSync) end
return true
end

12 changes: 6 additions & 6 deletions [Library]/assetify_library/utilities/syncer.lua
Original file line number Diff line number Diff line change
@@ -310,12 +310,12 @@ else
return network:emit("Assetify:onRecieveState", true, false, player, ...)
end

function syncer:syncGlobalData(data, value, targetPlayer)
function syncer:syncGlobalData(data, value, isForceSync, targetPlayer)
if not element or not imports.isElement(element) then return false end
if not targetPlayer then
thread:create(function(cThread)
for i, j in imports.pairs(syncer.loadedClients) do
syncer:syncGlobalData(data, value, i)
syncer:syncGlobalData(data, value, isForceSync, i)
thread:pause()
end
end):resume({
@@ -328,12 +328,12 @@ else
return true
end

function syncer:syncEntityData(element, data, value, targetPlayer)
function syncer:syncEntityData(element, data, value, isForceSync, targetPlayer)
if not targetPlayer then
if not element or not imports.isElement(element) then return false end
thread:create(function(cThread)
for i, j in imports.pairs(syncer.loadedClients) do
syncer:syncEntityData(element, data, value, i)
syncer:syncEntityData(element, data, value, isForceSync, i)
thread:pause()
end
end):resume({
@@ -563,12 +563,12 @@ else
thread:create(function(cThread)
local source = __source
for i, j in imports.pairs(syncer.syncedGlobalDatas) do
syncer:syncGlobalData(i, j, source)
syncer:syncGlobalData(i, j, false, source)
thread:pause()
end
for i, j in imports.pairs(syncer.syncedEntityDatas) do
for k, v in imports.pairs(j) do
syncer:syncEntityData(i, k, v, source)
syncer:syncEntityData(i, k, v, false, source)
thread:pause()
end
thread:pause()

0 comments on commit c1c9f6e

Please sign in to comment.