This function can make a throw to functions.lua in lib
Talkactions
Lua:
function cleanHousesByIdleTime(idletime)
local days = tonumber(idleTime)
if(not days or days <= 0) then
return 0
end
local checkTime = os.time() - days*3600*24
local result, i = db.getResult('SELECT `owner`, `world_id`, (SELECT `lastlogin` FROM `players` AS `b` WHERE `b`.`id`=`a`.`owner` AND `b`.`world_id`=`a`.`world_id`) AS `loggedLast` FROM `houses` AS `a` WHERE `loggedLast`<='..checkTime), 0
if(result:getID() == -1) then
return 0
end
repeat
if(setHouseOwner(result:getDataInt('id')), 0, true) then
i = i + 1
end
until not(result:next())
result:free()
return i
end
Lua:
function onSay(cid, words, param, channel)
if(param:len() <= 0) then
doPlayerSendCancel(cid, 'This command requires a numeric parameter - number of days. If any player has not logged on since the amount of days, his house will be cleared.')
return true
end
local days = tonumber(param)
if(not days or days <= 0) then
doPlayerSendCancel(cid, 'Written parameter is not a sufficient number of.')
return true
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'has been cleared ' .. cleanHousesByIdleTime(param) .. ' the houeses of the players who hasnt log in since' .. days .. ' days.')
return true
end
Last edited: