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

How to add server save!

Colandus

Advanced OT User
Senator
Joined
Jun 6, 2007
Messages
2,434
Solutions
19
Reaction score
220
Location
Sweden
Hey, I know this is supposed to be in script section, but I decided to post it here, since people might look here when they want to say "Me haf no server sejv!1!11!" xD

So, place this at bottom of global.lua:
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

And just change the delay of each save, and you're done ;)

Move if you really feel it shouldn't be here.
 
Last edited:
I think so... Is there any difference between GUI and console, at the scripts? If not, then it should work :)
 
Code:
if (getGlobalStorageValue(storageValue) == -1) then
    addEvent(autoSave, saveDelay, saveDelay)  
    setGlobalStorageValue(storageValue, 1)  
end
function autoSave(saveDelay)  
    saveData()  
    print(">>>>PLAYERS SAVED<<<<")  
    addEvent(save, saveDelay, saveDelay)  
end
blz?
 
Nah, mine is better :) If you even knew what the global storagevalue is for, then you might reply... But I just take that as spam!
 
Nah, mine is better :) If you even knew what the global storagevalue is for, then you might reply... But I just take that as spam!
Actually I know, buddy.
Your script checks for global value while loading global.lua, executes save event, and sets global value to prevent new events on reload.
But, the save function is between lines which are executed if the global value is -1 (doesn't exists).
So event wont find it, since it exists only if value = -1

><
btw, debugPrint rlz.
 
Actually I know, buddy.
Your script checks for global value while loading global.lua, executes save event, and sets global value to prevent new events on reload.
But, the save function is between lines which are executed if the global value is -1 (doesn't exists).
So event wont find it, since it exists only if value = -1

><
btw, debugPrint rlz.

Ehm...? You don't seem to know what you are talking about, why wouldn't it find it? All global variables are saved in the _G variable, and what makes you think it won't be load?

debugPrint sux, error rox ^^
 
Ehm...? You don't seem to know what you are talking about, why wouldn't it find it? All global variables are saved in the _G variable, and what makes you think it won't be load?

debugPrint sux, error rox ^^
Well, on my eye it seem to exist only if the value is -1 =p
But I may be wrong.
If so, then there isn't difference in work of your and mine 'modification'.
 
Well, on my eye it seem to exist only if the value is -1 =p
But I may be wrong.
If so, then there isn't difference in work of your and mine 'modification'.

Well, the difference ain't deadly, but it's waste? :P Like when you'll reload actions or stuff like that, the function save will reload aswell, but not in my script, since it will only be created if there is NO global storage value! :)
 
Ok great ;)

and a /save command:
PHP:
function onSay(cid)
    if (getPlayerGroupId(cid) >= 3) then
        saveData()
        doPlayerSendTextMessage(cid, 24, "Server saved.")
    else
        doPlayerSendCancel(cid, "You can not execute this command.")
    end
    return 1
end
l0ol :p
 
Last edited:
Well, the difference ain't deadly, but it's waste? :P Like when you'll reload actions or stuff like that, the function save will reload aswell, but not in my script, since it will only be created if there is NO global storage value! :)
Thats what I'm talking about.
So, any change of the function requires server restart :)
 
Thats what I'm talking about.
So, any change of the function requires server restart :)

Yeah, but... w/e xD

There isn't much to change is there? Only the delay, and they can still change it :)
 
Fix the talkaction so only players with access 3+ can use it?
 
Back
Top