<?xml version="1.0" encoding="UTF-8"?>
<mod name="Clean houses mod" version="1.0" author="nsanee" contact="otland.net" enabled="yes">
<description>
This mod will clean houses of inactive players and move their items to the depot.
config explained:
days - If the player hasn't logged in for this number of days his house will be freed.
log - true/false, whether to enable logging of which houses have been cleaned.
file - path to the log file, where logs will be stored. Ignored if 'log' set to false
DO NOT remove doSaveServer() at the end, otherwise if your server happens to crash before the nearest server save you will regret it =)
</description>
<config name="cleanhouses_conf"><![CDATA[
config = {
days = 7,
log = true,
file = getDataDir() .. "/logs/cleanhouses.txt"
}
]]></config>
<globalevent name="cleanhouses" type="start" event="buffer"><![CDATA[
domodlib('cleanhouses_conf')
local house = db.getResult("SELECT `owner` ,`id` FROM `houses` WHERE `owner` IN (SELECT `id` FROM `players` WHERE `lastlogin` < UNIX_TIMESTAMP() - "..config.days.. "*24*60*60)")
local logs = " :: Houses cleaned:\n\n"
if house:getID() ~= -1 then
repeat
logs = logs .. getHouseInfo(house:getDataInt('id')).name ..", owned by " .. getPlayerNameByGUID(house:getDataInt('owner')) .. "\n"
setHouseOwner(house:getDataInt('id'), 0)
until not house:next()
else
logs = logs .. "There were no houses to clean."
end
if config.log then
doWriteLogFile(config.file, logs)
end
doSaveServer()
]]></globalevent>
</mod>