Autor: nsanee
Licencja: nie wiem
Skąd: Link
Opracowanie: Moqill

Do globalevents.xml dodajemy:

<globalevent name="cleanhouses" type="start" event="script" value="cleanhouses.lua"/>

I do data/globalevents/script dodajemy cleanhouses.lua:

cleanhouses.lua
local config = { 
    days = 30,  -- po ilu dniach nieaktywnosci gracza ma byc czyszczony domek
    log = true, -- czy ma byc wlaczone zapisywanie logow z czyszczonych domkow
    file = getDataDir() .. "/logs/cleanhouses.txt" -- gdzie ma byc zapisywany plik logow
}    
local ns_query =[[ SELECT houses.owner,houses.id,players.name FROM houses
                LEFT JOIN players ON players.id=houses.owner
                WHERE players.lastlogin < (UNIX_TIMESTAMP() - ]] ..config.days.. [[*24*60*60)
                AND
                players.world_id =]] .. getConfigValue("worldId")
 
function onStartup(_time)
 
    local house = db.getResult(ns_query)
    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
otspub/czyszczenie_domow.txt · Last modified: 2010/04/28 23:15 by moqill
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
 otosowy pasek