• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent The BEST save system without server freeze!

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,766
Solutions
1
Reaction score
225
Location
Chile, Santiago
Bored of global saves that freeze your ot from 8-160 seconds?
I know it sux, and here is the solution: an individual save for each player after each login...

How it works?
Quite easy, when you log in, it activates an event every 30-40 minutes (random) and then it saves the character, so, you will be always saving a player at each minute, and you won't need a global save...

You will just have to set a global save to the hours when you have less players than normal, ie: 6:00 AM? And there you will save houses, so this won't affect wars, quests, etc...

ftw where is the custom saveRepeat function, you can't exclude it ;x
this is how I would do it

Lua:
function saveRepeat(cid)
    if not isPlayer(cid) then return true end
    doPlayerSave(cid)
    doPlayerSendTextMessage(cid,19, 'Your character\'s progress is saved.')
    doSendMagicEffect(getThingPos(cid), 11)
    save = addEvent(saveRepeat, math.random(30,43) *60*1000, cid)
end

function onLogin(cid)
    save = addEvent(saveRepeat, math.random(30,43)*60*1000, cid)
    return true
end

function onLogout(cid)
    stopEvent(save)
    return true
end

Lua:
<event type="login" name="saveOn" event="script" value="save.lua"/>
<event type="logout" name="saveOff" event="script" value="save.lua"/>
no need to register
---- on data/creaturescripts

Thanks to Cybershot, if you want to rep, just rep him, not me.
 
Last edited:
umm but what about a crash :/

btw its a cool script xD
 
umm but what about a crash :/

btw its a cool script xD

Anyways a crash f*ck up all houses, always players loses items, just change to linux with an stable rev, that if there is a crash, it is because your PC collapsed, like rev3684 0.4, for me, 3 crashes with 350+ players online all days in 1 month -- Those crashes where SQL conecction lost because of bans bug.

this save only the character and the houses?

Only will save players.
 
Its a good idea, but you can't really compare it with the normal save. But when using this script you can maybe delay the global save some more.
 
No, it's not the BEST save system. I'd rather re-write save system so it splits query to smaller and execute them in some intervals + separated save for houses. Also, what about separated thread so it wouldn't lag engine at all? :D
 
Last edited:
Its a good idea, but you can't really compare it with the normal save. But when using this script you can maybe delay the global save some more.

That's the idea, to delay the global save, because is a sh*t to be in war or in a quest like poi, doq, inqui, dcq, etc... And got freezed because a save, that's why I asked for it at requests and posting it here, because, it is very helpful.

No, it's not the BEST save system. I'd rather re-write save system so it splits query to smaller and execute them in some intervals + separated save for houses. Also, what about separated thread so it wouldn't lag engine at all? :D

Yeah, that would be really nice, but how to do it... The save for players could be this one, but for houses, it should be in other way, the idea is to get a save without freeze.
 
my server save is each 30 mins.
i think ill put it to like 4 hours after imput ur system :p
but instead of 30-40 mins
cant be like 25-30? :p
 
my server save is each 30 mins.
i think ill put it to like 4 hours after imput ur system :p
but instead of 30-40 mins
cant be like 25-30? :p

Yes, just change math.random(30,43) -- 30,43 means a random between 30 minutes or 43 minutes.
 
well i'd better rewrite it :p
 
:p just some config, nothing new
Lua:
local setup = {
    meffect = true,
    effect = CONST_ME_MAGIC_GREEN,
    minutesToSave = {30,40},
    text = 'Your character\'s progress has been saved.',
    type = MESSAGE_EVENT_ORANGE
}

function saveRepeat(cid)
    if not isPlayer(cid) then 
        return true 
    end
    if setup.meffect then
        doSendMagicEffect(getThingPos(cid), setup.effect)
    end
    doPlayerSave(cid)
    doPlayerSendTextMessage(cid, setup.type, setup.text)
    save = addEvent(saveRepeat, math.random(setup.minutesToSave[1],setup.minutesToSave[2])*60*1000, cid)
end
 
function onLogin(cid)
    save = addEvent(saveRepeat, math.random(setup.minutesToSave[1],setup.minutesToSave[2])*60*1000, cid)
    return true
end
 
function onLogout(cid)
    stopEvent(save)
    return true
end
 
Last edited:
No, just add this one, and set the global save every 12 hours, it will work perfect.

PD: I seted the global save at 12:00 PM and 00:00 AM.
 
Back
Top