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

GlobalEvent House Clean

Critico

Sexy
Joined
Mar 25, 2010
Messages
370
Reaction score
176
Description: Is to delete houses from inactive players, meaning that the player does not log in "X" days lose your house!

houseclean.lua
Lua:
function onTimer()
local days = 15*24*60*60
doSaveServer()
local query = db.getResult("SELECT `owner`,`id` FROM `houses`;")
if (query:getID() ~= -1) then
while true do
local own,houseid = query:getDataInt("owner"),query:getDataInt("id")
local qry = db.getResult("SELECT `lastlogin`  FROM `players` WHERE `id` = "..own)
if(qry:getID() ~= -1) then
last = tonumber(qry:getDataInt("lastlogin"))
if last < os.time() - days then
setHouseOwner(houseid, NO_OWNER_PHRASE,true)
end
end
if not(query:next()) then
break
end
end
query:free()
end
return true
end


globalevents.xml
Code:
<globalevent name="HouseClean" time="03:00" event="script" value="houseclean.lua"/>

the tag is to run the script at 3am, if you want to change, change this part::

Code:
time="03:00"

to configure the days that the player who did not log in "X" days is here:

Lua:
local days = 15*24*60*60
 
Back
Top