• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ What exactly is server saving?

Arkemis

Well-Known Member
Joined
Sep 4, 2021
Messages
90
Reaction score
68
Location
United States
TFS 1.3 (Nekiros 8.6 downgrade)
cip Client 8.6

I switched my server to save progress on an interval without shutting down. This is the script im using.
Lua:
local shutdownAtServerSave = false
local cleanMapAtServerSave = false

local function serverSave()
    if shutdownAtServerSave then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
        Game.setGameState(GAME_STATE_CLOSED)

        if cleanMapAtServerSave then
            cleanMap()
        end

        Game.setGameState(GAME_STATE_NORMAL)
    end
end


function onThink(interval)
    addEvent(saveData, 1000)
    return not shutdownAtServerSave
end

It functions fine.
unknown.png

but I've always wondered, if server save only happens at specific times, what is being saved, because if i log in and out between saves it appears everything im doing is being saved as i do it, live. Could someone please school me on exactly what is being saved at server save and why.
 
Solution
If I understood your question correctly, I think what confuses you is the fact that players get saved when they logout as well.. but if a crash happens and the server hasn't been saved yet a player could lose items, levels, etc.
If I understood your question correctly, I think what confuses you is the fact that players get saved when they logout as well.. but if a crash happens and the server hasn't been saved yet a player could lose items, levels, etc.
 
Solution
If I understood your question correctly, I think what confuses you is the fact that players get saved when they logout as well.. but if a crash happens and the server hasn't been saved yet a player could lose items, levels, etc.
I think you're exactly right mighty Rombadr! That's the clarification I needed. This son of a shepherd thanks you! The harvest moon will shine on your fields tonight!
 
I know for a fact that @kondra has a saving system that saves every set time, it even works with every single minute, and I believe it even saves the players online without lagging at all. Perhaps he can one day implement his code into the TFS 1.4, or at least tell us or show us how he did it for educational purposes.
 
MAybe done in a stagged way or something. The current tfs doesnt really accompdate long or locking connections. You'll notice it very clearly if for example you have you SQL hosted on 1 server and the world server running on another server (or otherwise from another location). locks when logging in/out/dying, etc. It's why multiworld also would be problematic, running multiuple processes to access the same sql data with both processes locking.

You could easily make a login script schedule an event to save the player every minute, on login they'd be staggered.

I had a quicksave running for a while while testing changes that would save all players, houses and world tile data hourly, and on the hour you could notice a small lock step. Not that noticable, looks like a small <1 second lag.
 
Back
Top