Thorn
Spriting since 2013
hii guys, i keep having this error [ua][06/07/2013 19:23:28] [Error - GlobalEvents::think] Couldn't execute event: cleanhouses[/code]
and here is my script, i have no idea what's wrong, why does not clean houses :S
plzz guys help me to make this script functional
and here is my script, i have no idea what's wrong, why does not clean houses :S
XML:
<globalevent name="cleanhouses" interval="86400" event="script" value="cleanhouses.lua"/>
Lua:
local config = {
days = 20,
log = true,
file = getDataDir() .. "/logs/cleanhouses.txt"
}
function onThink()
local house = db.getResult('SELECT houses.owner,houses.id,players.name FROM houses LEFT JOIN players ON players.id=houses.owner WHERE houses.town != 24 AND players.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 " .. house:getDataString('name') .. "\n"
setHouseOwner(house:getDataInt('id'), 0)
until not house:next()
house:free()
else
logs = logs .. "There were no houses to clean."
end
if config.log then
doWriteLogFile(config.file, logs)
end
addEvent(doSaveServer, 1000)
end
plzz guys help me to make this script functional