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

Furniture Package working outside houses tiles

Terotrificy

Veteran OT User
Joined
Oct 18, 2020
Messages
401
Solutions
13
Reaction score
254
Location
Santiago, Chile.
Hello, i'm having an issue in Othire 1.0 server, when i buy furniture in packages, it's supposed to not work inside the backpack or outside a house tile, however while the first condition works fine, i'm still able to unpack the furniture outside a house.
My intention is to make packpages openables only inside a house floor, seems like the validation is not working. Here is the code:



Lua:
-- by Nottinghster

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (CONSTRUCTIONS[item.itemid] == nil) then
        return false
    elseif (fromPosition.x == CONTAINER_POSITION) then
        doPlayerSendCancel(cid, "You must put the construction kit on the floor first.")
    elseif not(getTileHouseInfo(getPlayerPosition(cid)) ~= false) then
        doPlayerSendCancel(cid, "You must open the construction kit in your house.")
    else
        doTransformItem(item.uid, CONSTRUCTIONS[item.itemid])
        if item.actionid ~= 0 then
            doSetItemActionId(item.uid, item.actionid)
        end
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
    end
    
    return true
end
 
Solution
Is there a Github repository with the source of the server you're using?

I had a look at this https://github.com/peonso/OTHire/blob/master/source/luascript.cpp#L4534. I don't know if that is the same as what you have, but it looks like it returns false if the tile is not found at all, and 0 if the tile is valid, but not a house tile.

I broke up the elseif chain so it's a little easier to read IMO, and we can store the house info in a variable to check both if it's false or 0.
Lua:
-- by Nottinghster

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (CONSTRUCTIONS[item.itemid] == nil) then
        return false
    end
  
    if (fromPosition.x == CONTAINER_POSITION) then
        doPlayerSendCancel(cid, "You must...
Is there a Github repository with the source of the server you're using?

I had a look at this https://github.com/peonso/OTHire/blob/master/source/luascript.cpp#L4534. I don't know if that is the same as what you have, but it looks like it returns false if the tile is not found at all, and 0 if the tile is valid, but not a house tile.

I broke up the elseif chain so it's a little easier to read IMO, and we can store the house info in a variable to check both if it's false or 0.
Lua:
-- by Nottinghster

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (CONSTRUCTIONS[item.itemid] == nil) then
        return false
    end
  
    if (fromPosition.x == CONTAINER_POSITION) then
        doPlayerSendCancel(cid, "You must put the construction kit on the floor first.")
        return true
    end

    local house = getTileHouseInfo(fromPosition)
    if not house or house == 0 then
        doPlayerSendCancel(cid, "You must open the construction kit in your house.")
        return true
    end

    doTransformItem(item.uid, CONSTRUCTIONS[item.itemid])
    if item.actionid ~= 0 then
        doSetItemActionId(item.uid, item.actionid)
    end
    doSendMagicEffect(fromPosition, CONST_ME_POFF)
  
    return true
end
Edit: see below
 
Last edited:
Solution
Is there a Github repository with the source of the server you're using?

I had a look at this https://github.com/peonso/OTHire/blob/master/source/luascript.cpp#L4534. I don't know if that is the same as what you have, but it looks like it returns false if the tile is not found at all, and 0 if the tile is valid, but not a house tile.

I broke up the elseif chain so it's a little easier to read IMO, and we can store the house info in a variable to check both if it's false or 0.
Lua:
-- by Nottinghster

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (CONSTRUCTIONS[item.itemid] == nil) then
        return false
    end
   
    if (fromPosition.x == CONTAINER_POSITION) then
        doPlayerSendCancel(cid, "You must put the construction kit on the floor first.")
        return true
    end

    local house = getTileHouseInfo(getPlayerPosition(cid))
    if not house or house == 0 then
        doPlayerSendCancel(cid, "You must open the construction kit in your house.")
        return true
    end

    doTransformItem(item.uid, CONSTRUCTIONS[item.itemid])
    if item.actionid ~= 0 then
        doSetItemActionId(item.uid, item.actionid)
    end
    doSendMagicEffect(fromPosition, CONST_ME_POFF)
   
    return true
end
Should check the floor tile of where the item is, rather then the player position.
If item isn't in the player inventory, it makes more sense this way, and afaik is the way real tibia always checked it.

Lua:
local house = getTileHouseInfo(toPosition)
 
Should check the floor tile of where the item is, rather then the player position.
If item isn't in the player inventory, it makes more sense this way, and afaik is the way real tibia always checked it.

Lua:
local house = getTileHouseInfo(toPosition)
Good point. I didn't look too closely at that. Proof it's past my bedtime. :]
 
Thank you guys, indeed it works now, but as Xikini said above, if i'm standing in the door of a house, i still can use the package in the tiles outside the house. Struggling a bit how to check the position of the item in the floor rofl
 
Thank you guys, indeed it works now, but as Xikini said above, if i'm standing in the door of a house, i still can use the package in the tiles outside the house. Struggling a bit how to check the position of the item in the floor rofl
Just copy what I put in that reply. lol
 
Back
Top