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

Nice idea... Help.

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,766
Solutions
1
Reaction score
225
Location
Chile, Santiago
Can someone make a script that after random minutes (between 30-43) of a player loged in, then it saves the char, so you don't have the need to do a global save an freeze the server, and also it is not frequently that lot of players log in in the same time, just when you open the server and for that, a random.

Do you get it?

And also there should be a independiente saving house system, but I don't have any idea on how to.
 
Code:
function onLogin(cid)
	addEvent(saveRepeat(),math.random(30,43)*60*1000)
	return true
end

function saveRepeat(cid)
local v = getThingPos(cid)
	doPlayerSave(cid)
	doPlayerSendTextMessage(cid,19,"Your character's progress is saved.")
	doSendMagicEffect(v,11)
	addEvent(saveRepeat,math.random(30,43)*60*1000)
	return true
end
 
Code:
if isPlayer(cid) then
doPlayerSave(cid)
doPlayerSendTextMessage(cid,19,"Your character's progress is saved.")
addEvent(saveRepeat,math.random(30,43)*60*1000)
end
hmm?
 
Code:
if isPlayer(cid) then
doPlayerSave(cid)
doPlayerSendTextMessage(cid,19,"Your character's progress is saved.")
addEvent(saveRepeat,math.random(30,43)*60*1000)
end
hmm?

I couldn't get it, which is the point?

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

function saveRepeat(cid)
local v = getThingPos(cid)
	doPlayerSave(cid)
	doPlayerSendTextMessage(cid,19,"Your character's progress is saved.")
	doSendMagicEffect(v,11)
	addEvent(saveRepeat,math.random(30,43)*60*1000)
	return true
end

Thanks, but how this will stop if player log out, there should be a function that stop the event?
 
Thanks, but how this will stop if player log out, there should be a function that stop the event?
this
Code:
[COLOR=Red][B]if isPlayer(cid) then[/B][/COLOR]
doPlayerSave(cid)
doPlayerSendTextMessage(cid,19,"Your character's progress is saved.")
addEvent(saveRepeat,math.random(30,43)*60*1000)
end
hmm?
 
[18:54:31.975] [Error - CreatureScript Interface]
[18:54:31.975] data/creaturescripts/scripts/login.lua:eek:nLogin
[18:54:31.975] Description:
[18:54:31.975] (luaAddEvent) Callback parameter should be a function.


function onLogin(cid)
if isPlayer(cid) then
doPlayerSave(cid)
doPlayerSendTextMessage(cid,19,"Your character's progress is saved.")
addEvent(saveRepeat,math.random(1,1)*60*1000)
end
...
 
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
 
Last edited:
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

Thanks a lot, repped and added to tracker list as a feature.
 
Back
Top