Skip to content

Instantly share code, notes, and snippets.

@Zbizu
Created June 26, 2021 21:24
Show Gist options
  • Save Zbizu/8b6670310b0dd2964e34503a29f7824e to your computer and use it in GitHub Desktop.
Save Zbizu/8b6670310b0dd2964e34503a29f7824e to your computer and use it in GitHub Desktop.
less laggy player saving (tfs 1.3 or a fork that supports revscriptsys)
local noLagSave = GlobalEvent("noLagSave")
local timeBetweenSaves = 1 * 60 * 60 * 1000 -- in milliseconds
local delayBetweenSaves = 100
function delayedSave(cid)
local p = Player(cid)
if p then
p:save()
end
end
function noLagSave.onThink(interval, lastExecution)
local players = Game.getPlayers()
local delay = 0
for _, player in ipairs(players) do
delay = delay + delayBetweenSaves
addEvent(delayedSave, delay, player:getId())
end
end
noLagSave:interval(timeBetweenSaves)
noLagSave:register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment