local requiredTime = 60 * 60 * 24 * 10
function onThink(interval, lastExecution)
doSaveServer()
local result_plr = db.getResult("SELECT * FROM `houses`;")
if(result_plr:getID() ~= -1) then
while(true) do
local owner = tonumber(result_plr:getDataInt("owner"))
local hid = tonumber(result_plr:getDataInt("id"))
local lastlogin = 0
local result = db.getResult("SELECT * FROM `players` WHERE `id` = ".. owner ..";")
if(result:getID() ~= -1) then
while(true) do
lastlogin = tonumber(result:getDataInt("lastlogin"))
if not(result:next()) then
break
end
end
result:free()
end
if lastlogin <...
Console told you everything...This error appears to me in the console.
View attachment 56562
What could be the reason ?
How to fix it ?
TFS 0.4 Tibia 8.6show us the script and tell us which server engine you are using
local requiredTime = 60 * 60 * 24 * 10
function onThink(interval, lastExecution)
doSaveServer()
local result_plr = db.getResult("SELECT * FROM `houses`;")
if(result_plr:getID() ~= -1) then
while(true) do
local owner = tonumber(result_plr:getDataInt("owner"))
local hid = tonumber(result_plr:getDataInt("id"))
local lastlogin = 0
local result = db.getResult("SELECT * FROM `players` WHERE `id` = ".. owner ..";")
if(result:getID() ~= -1) then
while(true) do
lastlogin = tonumber(result:getDataInt("lastlogin"))
if not(result:next()) then
break
end
end
result:free()
end
if lastlogin < os.time(t) - requiredTime then
setHouseOwner(hid, 0, true)
end
if not(result_plr:next()) then
break
end
end
result_plr:free()
end
return TRUE
end
local requiredTime = 60 * 60 * 24 * 10
function onThink(interval, lastExecution)
doSaveServer()
local result_plr = db.getResult("SELECT * FROM `houses`;")
if(result_plr:getID() ~= -1) then
while(true) do
local owner = tonumber(result_plr:getDataInt("owner"))
local hid = tonumber(result_plr:getDataInt("id"))
local lastlogin = 0
local result = db.getResult("SELECT * FROM `players` WHERE `id` = ".. owner ..";")
if(result:getID() ~= -1) then
while(true) do
lastlogin = tonumber(result:getDataInt("lastlogin"))
if not(result:next()) then
break
end
end
result:free()
end
if lastlogin < (os.time() - requiredTime) then
setHouseOwner(hid, 0, true)
end
if not(result_plr:next()) then
break
end
end
result_plr:free()
end
return true
end
Thank you for your helpLua:local requiredTime = 60 * 60 * 24 * 10 function onThink(interval, lastExecution) doSaveServer() local result_plr = db.getResult("SELECT * FROM `houses`;") if(result_plr:getID() ~= -1) then while(true) do local owner = tonumber(result_plr:getDataInt("owner")) local hid = tonumber(result_plr:getDataInt("id")) local lastlogin = 0 local result = db.getResult("SELECT * FROM `players` WHERE `id` = ".. owner ..";") if(result:getID() ~= -1) then while(true) do lastlogin = tonumber(result:getDataInt("lastlogin")) if not(result:next()) then break end end result:free() end if lastlogin < (os.time() - requiredTime) then setHouseOwner(hid, 0, true) end if not(result_plr:next()) then break end end result_plr:free() end return true end
Np. So its works now? If everything wokrs fine mark as solvedThank you for your help
I think so. I'm waiting for the next save and clean to be sureNp. So its works now? If everything wokrs fine mark as solved
I also found such a script in the mod folder I also found such a script in the mod folder and I don't know if I should enable it.Np. So its works now? If everything wokrs fine mark as solved
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Cleanhouses" version="1.03" author="nsanee" contact="otland.net" 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 = 10,
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>
local requiredTime = 60 * 60 * 24 * 10
local requiredTime = 10
No no I cut down the time and everything will be clear soonLol
10h wait for test? For test change
toLua:local requiredTime = 60 * 60 * 24 * 10
You will get answer if script work in 10 sec.Lua:local requiredTime = 10
Everything looks fine, I can't see any bugs in the console. Thank you againLol
10h wait for test? For test change
toLua:local requiredTime = 60 * 60 * 24 * 10
You will get answer if script work in 10 sec.Lua:local requiredTime = 10