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

RevScripts leavehouse

alcapone

Member
Joined
Jan 13, 2021
Messages
246
Reaction score
19
Lua:
local leaveHouse = TalkAction("!leavehouse")

function leaveHouse.onSay(player, words, param)
    local position = player:getPosition()
    local tile = Tile(position)
    local house = tile and tile:getHouse()
    if not house then
        player:sendCancelMessage("You are not inside a house.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    if house:getOwnerGuid() ~= player:getGuid() then
        player:sendCancelMessage("You are not the owner of this house.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end
    local houseItems = house:getItems()
    if #houseItems > 10 then
        player:sendCancelMessage("Your house have items inside. Please remove it.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end
    house:setOwnerGuid(0)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have successfully left your house.")
    position:sendMagicEffect(CONST_ME_POFF)
    return false
end

leaveHouse:separator(" ")
leaveHouse:register()


I have a problem checking items even the house without any item reports that the house has items
 
Lua:
local leaveHouse = TalkAction("!leavehouse")

function leaveHouse.onSay(player, words, param)
    local position = player:getPosition()
    local tile = Tile(position)
    local house = tile and tile:getHouse()
    if not house then
        player:sendCancelMessage("You are not inside a house.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    if house:getOwnerGuid() ~= player:getGuid() then
        player:sendCancelMessage("You are not the owner of this house.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end
    local houseItems = house:getItems()
    if #houseItems > 10 then
        player:sendCancelMessage("Your house have items inside. Please remove it.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end
    house:setOwnerGuid(0)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have successfully left your house.")
    position:sendMagicEffect(CONST_ME_POFF)
    return false
end

leaveHouse:separator(" ")
leaveHouse:register()


I have a problem checking items even the house without any item reports that the house has items
It may count doors and windows. 'state' of these items is saved in database as they may be open/closed, so they are treated as house items.
 
Last edited:
Back
Top