Skip to content

Commit

Permalink
Added parameter sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ov-anisa committed Jun 12, 2022
1 parent 7ad656a commit 12d357b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions [Library]/assetify_library/exports/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, isForceSync)
function setGlobalData(data, value, isSync)
if imports.type(data) ~= "string" then return false end
syncer.syncedGlobalDatas[data] = value
if not localPlayer then syncer:syncGlobalData(data, value, isForceSync) end
if not localPlayer then syncer:syncGlobalData(data, value, isSync) end
return true
end

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

function setEntityData(element, data, value, isForceSync)
function setEntityData(element, data, value, isSync)
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, isForceSync) end
if not localPlayer then syncer:syncEntityData(element, data, value, isSync) end
return true
end

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

function syncer:syncGlobalData(data, value, isForceSync, targetPlayer)
function syncer:syncGlobalData(data, value, isSync, 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, isForceSync, i)
if not isForceSync then thread:pause() end
syncer:syncGlobalData(data, value, isSync, i)
if not isSync then thread:pause() end
end
end):resume({
executions = (not isForceSync and downloadSettings.syncRate) or 1,
frames = (not isForceSync and 1) or 0
executions = (not isSync and downloadSettings.syncRate) or 1,
frames = (not isSync and 1) or 0
})
else
network:emit("Assetify:onRecieveSyncedGlobalData", true, false, targetPlayer, data, value)
end
return true
end

function syncer:syncEntityData(element, data, value, isForceSync, targetPlayer)
function syncer:syncEntityData(element, data, value, isSync, 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, isForceSync, i)
if not isForceSync then thread:pause() end
syncer:syncEntityData(element, data, value, isSync, i)
if not isSync then thread:pause() end
end
end):resume({
executions = (not isForceSync and downloadSettings.syncRate) or 1,
frames = (not isForceSync and 1) or 0
executions = (not isSync and downloadSettings.syncRate) or 1,
frames = (not isSync and 1) or 0
})
else
network:emit("Assetify:onRecieveSyncedEntityData", true, false, targetPlayer, element, data, value)
Expand Down

0 comments on commit 12d357b

Please sign in to comment.