local function getGuildName(id)
local ret = false
local query = db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. id .. ";")
if(query:getID() ~= -1) then
ret = query:getDataString("name")
query:free()
end
return ret
end
local function getPlayerGuildByGUID(guid)
local ret = 0
local query = db.getResult("SELECT `guild_ranks`.`guild_id` FROM `players`, `guild_ranks` WHERE `players`.`id` = " .. guid .. " AND `guild_ranks`.`id` = `players`.`rank_id` LIMIT 1;")
if(query:getID() ~= -1) then
ret = query:getDataInt("guild_id")
query:free()
end
return ret
end
function onLook(cid, thing, position, lookDistance)
if isItemDoor(thing.itemid) then
local house, ret = getHouseFromPos(position), ""
if(house) then
local guildHall = getHouseInfo(house).guildHall
if(house > 0) then
ret = "It belongs to " .. (guildHall and "hall" or "house") .. " " .. getHouseInfo(house).name .. ". " .. (guildHall and "Guild " .. getGuildName(getPlayerGuildByGUID(getHouseInfo(house).owner)) or getPlayerNameByGUID(getHouseInfo(house).owner)) .. " owns this this " .. (guildHall and "hall" or "house") .. "."
else
ret = "It belongs to " .. (guildHall and "hall" or "house") .. " " .. getHouseInfo(house).name .. ". Nobody owns this this " .. (guildHall and "hall" or "house") .. ". It costs " .. getHouseInfo(house).price .. " gold coins."
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ret)
end
end
return true
end