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

Auto save

Adrish

New Member
Joined
Jan 27, 2008
Messages
221
Reaction score
2
Location
Sweden
Need a auto save for the forgotten server 8.1

I want so it save houses etc.
 
Use an NPC Saver.

NPC File:
Code:
<npc name="tehsaver" script="data/npc/scripts/save.lua" autowalk="1" floorchange="0">
	<health now="100" max="100"/>
	<look type="143" head="114" body="114" legs="0" feet="0" addons="2"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|."/>
	</parameters>
</npc>

Save Code
Code:
local SAVE_FREQUENCE = 600 -- seconds

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local saveTimer = SAVE_FREQUENCE

function onCreatureAppear(cid)			npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid)		npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)	npcHandler:onCreatureSay(cid, type, msg)	end
function onThink()
	saveTimer = saveTimer - 1
	if saveTimer == 0 then
		saveData()
		print("Server save...")
		saveTimer = SAVE_FREQUENCE
	end
end
npcHandler:addModule(FocusModule:new())

How it works: Each second, save timer is decremented by 1. When it reaches 0, the server saves and the timer is reset to whatever you have SAVE_FREQUENCE set to.

How to get it to work: Properly configure and setup the NPC. Then simple either add it into your map somewhere or summon with with /s NPCNAME

~code retrieved from trunk~
 
Use an NPC Saver.

NPC File:
Code:
<npc name="tehsaver" script="data/npc/scripts/save.lua" autowalk="1" floorchange="0">
    <health now="100" max="100"/>
    <look type="143" head="114" body="114" legs="0" feet="0" addons="2"/>
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|."/>
    </parameters>
</npc>

Save Code
Code:
local SAVE_FREQUENCE = 600 -- seconds

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local saveTimer = SAVE_FREQUENCE

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)    npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()
    saveTimer = saveTimer - 1
    if saveTimer == 0 then
        saveData()
        print("Server save...")
        saveTimer = SAVE_FREQUENCE
    end
end
npcHandler:addModule(FocusModule:new())

How it works: Each second, save timer is decremented by 1. When it reaches 0, the server saves and the timer is reset to whatever you have SAVE_FREQUENCE set to.

How to get it to work: Properly configure and setup the NPC. Then simple either add it into your map somewhere or summon with with /s NPCNAME

~code retrieved from trunk~
Working on TFS 1.3! :D
Just need to change saveData() to saveServer().
And can add cleanMap().
 
Back
Top