ugurdrahs
New Member
Clean Non-Active Houses
safelist values are the id of certain houses you don't want to check.
days number of days a player has to be inactive to clear the house (10 days).
Lua Code:
Add this to your talkactions.xml:
Lua Code:
<talkaction words="/cleanhouses" script="houseclean.lua"/>
Will this one works for 0.4???
safelist values are the id of certain houses you don't want to check.
days number of days a player has to be inactive to clear the house (10 days).
Lua Code:
PHP:
--Adam 2008 Edited by Teh Maverick to work in 0.2+
--Config
local safelist = {1,2}
local days = 10*3600*24
--Leave these
local ownerr = 0
local hid = 0
local pid = 0
local lastlogin = 0
local cleared = 0
local name = ""
local house = nil
local player = nil
local playerID = nil
local cur = nil
local cur2 = nil
function onSay(cid, words, param)
if getPlayerGroupId(cid) > 2 then
pdelete = "Inactive Players With Houses:\n\n"
t=os.date('*t')
dofile("./config.lua")
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
local houseID = assert(con:execute("SELECT `owner` FROM `houses` WHERE `owner` > 0"))
local houseCount = numRows(houseID)
cur = assert(con:execute("SELECT `owner`, `id` FROM `houses` WHERE `owner` > 0"))
house = cur:fetch({}, "a")
cur:close()
if(houseCount >= 1) then
for owner, id in rows(con, "SELECT `owner`, `id` FROM `houses` WHERE `owner` > 0 ORDER BY `id` DESC;") do
ownerr = tonumber(owner)
hid = tonumber(id)
playerID = assert(con:execute("SELECT `id` FROM `players` WHERE `id` = '"..ownerr.."' "))
cur2 = assert(con:execute("SELECT `id`,`name`,`lastlogin` FROM `players` WHERE `id` = '"..ownerr.."' "))
player = cur2:fetch({}, "a")
cur2:close()
if(numRows(playerID) >= 1) then
lastlogin = player.lastlogin
pid = player.id
name = player.name
time=os.time(t) - lastlogin
offline = time - days
if offline >= 0 then
pdelete = pdelete.."House #"..hid.." owned by "..name.."\n"
if isInArray(safelist,hid) == FALSE then
setHouseOwner(hid, 0)
cleared=cleared+1
end
end
player = nil
end
end
if cleared < 1 then
pdelete = "No players have been inactive.\n"
end
doShowTextDialog(cid, 5958, pdelete.."\n"..cleared.." Houses cleared.")
else
doPlayerSendCancel(cid, "No one owns any houses")
print('No one owns any houses')
end
house = nil
con:close()
env:close()
end
return TRUE
end
Lua Code:
<talkaction words="/cleanhouses" script="houseclean.lua"/>
Will this one works for 0.4???
Last edited: