• 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!

Npc Saver

sonny11

New Member
Joined
Dec 22, 2007
Messages
137
Reaction score
0
hello, since tfs only saves 1 time a day
that means if im not around and it crashes sometimes people lose 10lvls
so is there any npc that saves every 5-10mins
ive seen some but they are confusing and the 1 i have already doesnt even save it
 
PHP:
saveDelay = 10 * 60 * 1000 -- 10 minutes for each save.
storageValue = 2342

if (getGlobalStorageValue(storageValue) == -1) then
    function save(saveDelay)
        saveData()
        addEvent(save, saveDelay, saveDelay)
    end
    addEvent(save, saveDelay, saveDelay)
    setGlobalStorageValue(storageValue, 1)
end

Try adding that in global.lua, if it fucks up, then try adding it in actions.lua in actions/lib but keep the saveDelay in global.lua :p

I also THINK that in newest TFS it's not savePlayers, it's maybe like saveFiles or something like that. Code not tested, but this should work.

The global storage value is added so when you reload global.lua or so, that will not be reloaded. Without the global storage value, if you would have reloaded global.lua it would delay the save extra 10 minutes ^.-
 
Last edited:
At bottom if you feel that's best. If it gives you errors, try putting it in data/actions/lib/actions.lua instead.
 
server opened with no errors
presuming its working but gna shutdown the server without me saying /save
and im going to a differrent part of my map to test it i will reply in about 5 minutes :) with the answer :p ty colandus
 
Just tested it using the latest rev, and it works perfect. just add the code to the bottom of your global.lua

I added some code to the source so i could see when it saved.
Code:
[23/02/2008  19:18:22] > > > > > > > Players saved < < < < < < <
[23/02/2008  19:19:23] > > > > > > > Players saved < < < < < < <
[23/02/2008  19:20:23] > > > > > > > Players saved < < < < < < <
[23/02/2008  19:21:24] > > > > > > > Players saved < < < < < < <
 
Last edited:
works thank you very much colandus

REP+++++++++++++++++++++++++++++

:p <3

huh never knew it says
[23/02/2008 19:21:24] > > > > > > > Players saved < < < < < < <

i dont think it does for me or did u add something?

im using the console
not the gui
 
Last edited by a moderator:
Like i said in my previous post, i added some code to the source.
If you want the same thing then do the following:
In game.cpp after
PHP:
    g_bans.saveBans();
    map->saveMap();
add
PHP:
    std::cout << "> > > > > > > Players saved < < < < < < <" << std::endl;
 
na i cant compile, it screws up eery time i try ive tryed all the tutorials too, it would be very helpful if you gave me your .exe that would be very helpful and nice :)
 
Like i said in my previous post, i added some code to the source.
If you want the same thing then do the following:
In game.cpp after
PHP:
    g_bans.saveBans();
    map->saveMap();
add
PHP:
    std::cout << "> > > > > > > Players saved < < < < < < <" << std::endl;

That's just waste? Why not just place that in the script i made.
PHP:
saveDelay = 10 * 60 * 1000 -- 10 minutes for each save.
storageValue = 2342

if (getGlobalStorageValue(storageValue) == -1) then
    function save(saveDelay)
        saveData()
        print(">>>>PLAYERS SAVED<<<<")
        addEvent(save, saveDelay, saveDelay)
    end
    addEvent(save, saveDelay, saveDelay)
    setGlobalStorageValue(storageValue, 1)
end
If you wanted it to write to a file, just use io.write... http://www.lua.org/pil/21.1.html


Glad it works ;);)
 
Last edited:
Update:
PHP:
saveDelay = 10 * 60 * 1000 -- 10 minutes for each save.
storageValue = 2342
saveFile = {folder="logs/", filename="saves.txt", text="Server save...", saveLog=true}

if (getGlobalStorageValue(storageValue) == -1) then
    function save(saveDelay)
        saveData()
        print(saveFile.text)
        local saveFile = {folder="logs/", filename="saves.txt", text="Server save...", saveLog=true, linesMax=1000}
        if (saveFile.saveLog == true) then
            local lines = 0
            for _ in io.lines(saveFile.folder .. saveFile.filename) do
                lines = lines+1
            end
            local file = io.open(saveFile.folder .. saveFile.filename, (lines < linesMax-1 and "a") or "w")
            file:write("[" .. os.date("%Y-%m-%d %H:%M:%S") .. "] " .. saveFile.text .. "\n")
            file:close()
        end
        addEvent(save, saveDelay, saveDelay)
    end
    addEvent(save, saveDelay, saveDelay)
    setGlobalStorageValue(storageValue, 1)
end
Now it's written to a log when it saved, quite unnecessary but anyways xD

It resets at 1000 saves :p
 
Last edited:
smmoooooooooooooooth :p
nice tht it resets after 1000 saves but i save every 7 mins and my server is like 20/7 :p

i like ur 1st script easy too see in console nice too see you update it
 
You still see in the console :p But I know it's not very usefull to see in a logg when it's saved, since you already know when it is saved xD
 
Last edited:
Back
Top