function onSay(cid, words, param, channel)
local house = getHouseFromPos(getPositionByDirection(getThingPosition(cid),
getCreatureLookDirection(cid)))
if (not house) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You aren't looking at house's door.")
else
local owner = getHouseInfo(houseId).owner
if (owner == 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You may buy this house via standard command: alana res.")
else
local result = db.getResult("SELECT `lastlogin` FROM `players` WHERE `id` = ".. owner ..";")
if (result:getId() ~= -1) then
if (result:getDataInt("lastlogin") + 35 * 24 * 60 * 60 > os.time()) then
setHouseOwner(house, 0, true)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You may buy this house via standard command: alana res")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This flat is already owned by someone else.")
end
else
setHouseOwner(house, 0, true)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You may buy this house via standard command: alana res")
end
end
end
return true
end