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

error in clean houses script :/

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
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

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
 
Ok man i will check it out, but i was wondering, in my script it says interval: 86400 (a day) that means that every 24 hours the script check if a player hasn't logged in 20 days to erase his house??
 
If that is being correct, yes. It will check it 24 hours after you've started your server, but if you do a /reload globalevents with your GOD/CM you'll reset the time.. I rather suggest you to put your script like this:

Check red marked code:
Code:
<globalevent name="cleanhouses" [COLOR="#FF0000"]time="21:35:11"[/COLOR] event="script" value="cleanhouses.lua"/>

You should either make it execute whenever you restart your server IF you do it on a daily basis, or put a time like 23:59:59 or something to make it execute once a day :)
 
Last edited:
Back
Top