-
-
Save Codinablack/2dfee820907b22b46db22f423b0f4c17 to your computer and use it in GitHub Desktop.
less laggy player saving (tfs 1.3 or a fork that supports revscriptsys)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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