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

TFS 0.X 8.60 0.4 MOD MYSQL THERE IS HOW TO DO IT SQLITE

Enderlop

Banned User
Joined
Jan 10, 2024
Messages
93
Reaction score
16
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Cleanhouses" version="1.03" author="nsanee" contact="tibiaking.com" enabled="yes">
    <description>
        v.1.03 - Added 'onlyNonPremium' configurable.
                 Removed modlib, since the script is run once anyway we don't need it loaded at all times.
                 It shouldn't now stop execution when a house is nameless.
                
        v.1.02 - now uses only one sql query, removed multiworld configurable  since it's not needed anymore
        v.1.01 - small fixes, optimized query + multiworld support.
      
        
        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
            onlyNonPremium - if set to 'true', the script will clean only the houses of players who don't have any pacc days left.
            
        other notes:
            DO NOT remove doSaveServer() at the end, otherwise if your server happens to crash before the nearest server save you will regret it =)
    </description>

    <globalevent name="cleanhouses" type="start" event="buffer"><![CDATA[
    
    
        local config = {
            days = 7,
            log = true,
            file = getDataDir() .. "/logs/cleanhouses.txt",
        onlyNonPremium = true
        }
        
        
        
        local ns_query =[[ SELECT houses.owner, houses.id as hid, houses.name as house_name ,players.name FROM houses
            LEFT JOIN players ON players.id=houses.owner
            LEFT JOIN accounts ON players.account_id=accounts.id
            WHERE players.lastlogin < (UNIX_TIMESTAMP() - ]] ..config.days.. [[*24*60*60)
            ]] ..(config.onlyNonPremium and ' AND accounts.premdays=0 ' or '')..[[
            AND    players.world_id =]] .. getConfigValue("worldId")
        
        local house = db.getResult(ns_query)
        local logs = " :: Houses cleaned:\n\n"
        if house:getID() ~= -1 then
            repeat
                logs = logs .. house:getDataString('house_name') ..", owned by " .. house:getDataString('name') .. "\n"
                setHouseOwner(house:getDataInt('hid'), 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)
        
    ]]></globalevent>
</mod>
 
Solution
Henk made this, might work, might not, be careful.


Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Cleanhouses" version="1.03" author="nsanee" contact="tibiaking.com" enabled="yes">
    <description>
        v.1.03 - Added 'onlyNonPremium' configurable.
                 Removed modlib, since the script is run once anyway we don't need it loaded at all times.
                 It shouldn't now stop execution when a house is nameless.
                
        v.1.02 - now uses only one sql query, removed multiworld configurable since it's not needed anymore
        v.1.01 - small fixes, optimized query + multiworld support.
      
        
        This mod will clean houses of inactive players and move their items to the depot...
Henk made this, might work, might not, be careful.


Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Cleanhouses" version="1.03" author="nsanee" contact="tibiaking.com" enabled="yes">
    <description>
        v.1.03 - Added 'onlyNonPremium' configurable.
                 Removed modlib, since the script is run once anyway we don't need it loaded at all times.
                 It shouldn't now stop execution when a house is nameless.
                
        v.1.02 - now uses only one sql query, removed multiworld configurable since it's not needed anymore
        v.1.01 - small fixes, optimized query + multiworld support.
      
        
        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
            onlyNonPremium - if set to 'true', the script will clean only the houses of players who don't have any pacc days left.
            
        other notes:
            DO NOT remove doSaveServer() at the end, otherwise if your server happens to crash before the nearest server save you will regret it =)
    </description>

    <globalevent name="cleanhouses" type="start" event="buffer"><![CDATA[
    
        local config = {
            days = 7,
            log = true,
            file = getDataDir() .. "/logs/cleanhouses.txt",
            onlyNonPremium = true
        }
        
        local ns_query = [[
            SELECT houses.owner, houses.id as hid, houses.name as house_name, players.name
            FROM houses
            LEFT JOIN players ON players.id = houses.owner
            LEFT JOIN accounts ON players.account_id = accounts.id
            WHERE players.lastlogin < (strftime('%s', 'now') - ]] .. config.days * 24 * 60 * 60 .. [[)
            ]] .. (config.onlyNonPremium and ' AND accounts.premdays = 0 ' or '') .. [[
            AND players.world_id = ]] .. getConfigValue("worldId")
        
        local house = db.getResult(ns_query)
        local logs = " :: Houses cleaned:\n\n"
        
        if house:getID() ~= -1 then
            repeat
                logs = logs .. house:getDataString('house_name') .. ", owned by " .. house:getDataString('name') .. "\n"
                setHouseOwner(house:getDataInt('hid'), 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)
        
    ]]></globalevent>
</mod>
 
Solution

@Tenzhiro It's giving a bug​

XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Cleanhouses" version="1.03" author="nsanee" contact="tibiaking.com" enabled="yes">
    <description>
        v.1.03 - Added 'onlyNonPremium' configurable.
                 Removed modlib, since the script is run once anyway we don't need it loaded at all times.
                 It shouldn't now stop execution when a house is nameless.
                
        v.1.02 - now uses only one sql query, removed multiworld configurable since it's not needed anymore
        v.1.01 - small fixes, optimized query + multiworld support.
      
        
        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
            onlyNonPremium - if set to 'true', the script will clean only the houses of players who don't have any pacc days left.
            
        other notes:
            DO NOT remove doSaveServer() at the end, otherwise if your server happens to crash before the nearest server save you will regret it =)
    </description>

    <globalevent name="cleanhouses" type="start" event="buffer"><![CDATA[
    
        local config = {
            days = 7,
            log = true,
            file = getDataDir() .. "/logs/cleanhouses.txt",
            onlyNonPremium = true
        }
        
        local ns_query = [[
            SELECT houses.owner, houses.id as hid, houses.name as house_name, players.name
            FROM houses
            LEFT JOIN players ON players.id = houses.owner
            LEFT JOIN accounts ON players.account_id = accounts.id
            WHERE players.lastlogin < (strftime('%s', 'now') - ]] .. config.days * 24 * 60 * 60 .. [[)
            ]] .. (config.onlyNonPremium and ' AND accounts.premdays = 0 ' or '') .. [[
            AND players.world_id = ]] .. getConfigValue("worldId")
        
        local house = db.getResult(ns_query)
        local logs = " :: Houses cleaned:\n\n"
        
        if house:getID() ~= -1 then
            repeat
                logs = logs .. house:getDataString('house_name') .. ", owned by " .. house:getDataString('name') .. "\n"
                setHouseOwner(house:getDataInt('hid'), 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)
        
    ]]></globalevent>
</mod>

XML:
[07/03/2024 22:09:02] [Error - GlobalEvent Interface]
[07/03/2024 22:09:02] buffer
[07/03/2024 22:09:02] Description:
[07/03/2024 22:09:02] (luaSetHouseOwner) House not found

[07/03/2024 22:09:03] [Error - GlobalEvent Interface]
[07/03/2024 22:09:03] buffer
[07/03/2024 22:09:03] Description:
[07/03/2024 22:09:03] (luaSetHouseOwner) House not found

[07/03/2024 22:09:04] [Error - GlobalEvent Interface]
[07/03/2024 22:09:04] buffer
[07/03/2024 22:09:04] Description:
[07/03/2024 22:09:04] (luaSetHouseOwner) House not found

[07/03/2024 22:09:05] [Error - GlobalEvent Interface]
[07/03/2024 22:09:05] buffer
[07/03/2024 22:09:05] Description:
[07/03/2024 22:09:05] (luaSetHouseOwner) House not found

[07/03/2024 22:09:06] [Error - GlobalEvent Interface]
[07/03/2024 22:09:06] buffer
[07/03/2024 22:09:06] Description:
[07/03/2024 22:09:07] (luaSetHouseOwner) House not found

[07/03/2024 22:09:07] [Error - GlobalEvent Interface]
[07/03/2024 22:09:07] buffer
[07/03/2024 22:09:07] Description:
[07/03/2024 22:09:08] (luaSetHouseOwner) House not found

[07/03/2024 22:09:08] [Error - GlobalEvent Interface]
[07/03/2024 22:09:08] buffer
[07/03/2024 22:09:08] Description:
[07/03/2024 22:09:09] (luaSetHouseOwner) House not found

[07/03/2024 22:09:09] [Error - GlobalEvent Interface]
[07/03/2024 22:09:09] buffer
[07/03/2024 22:09:10] Description:
[07/03/2024 22:09:10] (luaSetHouseOwner) House not found

[07/03/2024 22:09:10] [Error - GlobalEvent Interface]
[07/03/2024 22:09:10] buffer
[07/03/2024 22:09:11] Description:
[07/03/2024 22:09:11] (luaSetHouseOwner) House not found

[07/03/2024 22:09:11] [Error - GlobalEvent Interface]
[07/03/2024 22:09:11] buffer
[07/03/2024 22:09:12] Description:
[07/03/2024 22:09:12] (luaSetHouseOwner) House not found
 
@Dakos MYSQL TO SQLITE This mod is in MySQL I want it to become sqlite



XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Cleanhouses" version="1.03" author="nsanee" contact="tibiaking.com" enabled="no">
    <description>
        v.1.03 - Added 'onlyNonPremium' configurable.
                 Removed modlib, since the script is run once anyway we don't need it loaded at all times.
                 It shouldn't now stop execution when a house is nameless.
                
        v.1.02 - now uses only one sql query, removed multiworld configurable  since it's not needed anymore
        v.1.01 - small fixes, optimized query + multiworld support.
      
        
        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
            onlyNonPremium - if set to 'true', the script will clean only the houses of players who don't have any pacc days left.
            
        other notes:
            DO NOT remove doSaveServer() at the end, otherwise if your server happens to crash before the nearest server save you will regret it =)
    </description>

    <globalevent name="cleanhouses" type="start" event="buffer"><![CDATA[
    
    
        local config = {
            days = 15,
            log = true,
            file = getDataDir() .. "/logs/cleanhouses.txt",
        onlyNonPremium = true
        }
        
        
        
        local ns_query =[[ SELECT houses.owner, houses.id as hid, houses.name as house_name ,players.name FROM houses
            LEFT JOIN players ON players.id=houses.owner
            LEFT JOIN accounts ON players.account_id=accounts.id
            WHERE players.lastlogin < (UNIX_TIMESTAMP() - ]] ..config.days.. [[*24*60*60)
            ]] ..(config.onlyNonPremium and ' AND accounts.premdays=0 ' or '')..[[
            AND    players.world_id =]] .. getConfigValue("worldId")
        
        local house = db.getResult(ns_query)
        local logs = " :: Houses cleaned:\n\n"
        if house:getID() ~= -1 then
            repeat
                logs = logs .. house:getDataString('house_name') ..", owned by " .. house:getDataString('name') .. "\n"
                setHouseOwner(house:getDataInt('hid'), 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)
        
    ]]></globalevent>
</mod>
 
Otland banned his account, which is Samuel's. Now he's created several accounts, xD. The famous Samuel creating more than 1000 posts per year, xD.
Post automatically merged:

?? xD someone rly understood this topic?
He wants to say that this script, which is MySQL, needs someone to convert it to SQLite, that's it. He always posts very short texts/phrases... Sometimes it's hard to understand, haha. The famous Samuel!
 
Back
Top