- Joined
- Aug 4, 2008
- Messages
- 376
- Reaction score
- 37
ChannelServer
Save this as AutoSave.js, and add to world.prop events list AutoSave
To justify the auto save time...
change the
to the intervals you want.
Change
to the autosave interval
Now find the number of seconds for your interval and replace 'SECONDS' with it.
So if your doing 1 minute, it'll be 60. If your doing 10 minutes, then its 60 x 10, which is 600. 1 hour is 60 x 60, which is 3600, and so on
PHP:
public void saveAll() {
for (MapleCharacter chr : players.getAllCharacters()) {
chr.saveToDB(true, true);
}
}
Save this as AutoSave.js, and add to world.prop events list AutoSave
PHP:
var setupTask;
function init() {
scheduleNew();
}
function scheduleNew() {
var cal = java.util.Calendar.getInstance();
cal.set(java.util.Calendar.HOUR, 0);
cal.set(java.util.Calendar.MINUTE, 10);
cal.set(java.util.Calendar.SECOND, 0);
var nextTime = cal.getTimeInMillis();
while (nextTime <= java.lang.System.currentTimeMillis()) {
nextTime += 1000 * SECONDS;
}
setupTask = em.scheduleAtTimestamp("start", nextTime);
}
function cancelSchedule() {
setupTask.cancel(true);
}
function start() {
scheduleNew();
em.getChannelServer().saveAll();
var iter = em.getInstances().iterator();
while (iter.hasNext()) {
var eim = iter.next();
}
}
To justify the auto save time...
change the
PHP:
cal.set(java.util.Calendar.HOUR, 0);
cal.set(java.util.Calendar.MINUTE, 10);
cal.set(java.util.Calendar.SECOND, 0);
Change
PHP:
nextTime += 1000 * SECONDS;
Now find the number of seconds for your interval and replace 'SECONDS' with it.
So if your doing 1 minute, it'll be 60. If your doing 10 minutes, then its 60 x 10, which is 600. 1 hour is 60 x 60, which is 3600, and so on
Last edited: