• 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

Well-Known Member
Joined
Oct 18, 2020
Messages
247
Solutions
9
Reaction score
81
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...

forgee

Veteran OT User
Joined
May 9, 2011
Messages
321
Solutions
16
Reaction score
270
Location
Sweden
GitHub
forgee
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

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,699
Solutions
408
Reaction score
3,810
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)
 

forgee

Veteran OT User
Joined
May 9, 2011
Messages
321
Solutions
16
Reaction score
270
Location
Sweden
GitHub
forgee
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. :]
 
OP
OP
Terotrificy

Terotrificy

Well-Known Member
Joined
Oct 18, 2020
Messages
247
Solutions
9
Reaction score
81
Location
Santiago, Chile.
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
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,699
Solutions
408
Reaction score
3,810
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
 
Top