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

TFS 1.X+ items used only inside the house tfss 1.5

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
883
Solutions
7
Reaction score
123
Location
Brazil
YouTube
caruniawikibr
hello, I'm using a script to change beds, but I realized that I can use it outside the house, could anyone tell me how to make it to be used only inside the house?
i use 1.5 nekiro.

this line does not recognize the house i believe it
if getTileHouseInfo(getPlayerPosition(cid)) ~= 0 then


Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local BEDSINUSE = {1762, 1764, 3842, 1768, 5591, 5593,  5595,  5597,  5599,  5601}
local horizontalpos = {x = toPosition.x+1, y = toPosition.y, z = toPosition.z, stackpos = 1}
local horizontal = getThingfromPos(horizontalpos)
local verticalpos = {x = toPosition.x, y = toPosition.y+1, z = toPosition.z, stackpos = 1}
local vertical = getThingfromPos(verticalpos)

if getTileHouseInfo(getPlayerPosition(cid)) ~= 0 then
if item.itemid == 5603 then --bed kit
if itemEx.itemid == 1756 or itemEx.itemid == 3838 then
doTransformItem(itemEx.uid, 1760)
doTransformItem(horizontal.uid, 1761)
doRemoveItem(item.uid,1)
elseif itemEx.itemid == 3836 or itemEx.itemid == 1858 then
doTransformItem(itemEx.uid, 1754)
doTransformItem(vertical.uid, 1755)
doRemoveItem(item.uid,1)
elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Somebody is sleeping there!")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only use modification kits on empty beds.")
end
elseif item.itemid == 5604 then --hammok bed kit
if itemEx.itemid == 1760 or  itemEx.itemid == 1756 then
doTransformItem(itemEx.uid, 3838)
doTransformItem(horizontal.uid, 3839)
doRemoveItem(item.uid,1)
elseif itemEx.itemid == 1754 or itemEx.itemid == 1758 then
doTransformItem(itemEx.uid, 3836)
doTransformItem(vertical.uid, 3837)
doRemoveItem(item.uid,1)
elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Somebody is sleeping there!")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only use modification kits on empty beds.")
end
elseif item.itemid == 5605 then --cot bed kit
if itemEx.itemid == 1760 or itemEx.itemid == 3838 then
doTransformItem(itemEx.uid, 1756)
doTransformItem(horizontal.uid, 1757)
doRemoveItem(item.uid,1)
elseif itemEx.itemid == 1754 or itemEx.itemid == 3836 then
doTransformItem(itemEx.uid, 1758)
doTransformItem(vertical.uid, 1759)
doRemoveItem(item.uid,1)
elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Somebody is sleeping there!")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only use modification kits on empty beds.")
end
elseif item.itemid == 5606 then --Esse nao fiz ainda--
if itemEx.itemid == 7813 or itemEx.itemid == 7817 or itemEx.itemid == 7821 then
doTransformItem(itemEx.uid, 1760)
doTransformItem(horizontal.uid, 1761)
doRemoveItem(item.uid,1)
elseif itemEx.itemid == 7811 or itemEx.itemid == 7815 or itemEx.itemid == 7819 then
doTransformItem(itemEx.uid, 1754)
doTransformItem(vertical.uid, 1755)
doRemoveItem(item.uid,1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only use this on modified empty beds.")
end
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only use this inside a house.")
end
end
 
Solution
this script doesn't work for me, I've already tested it once, so I'm using the one above. mine is 7.72 I don't know if that interferes. but it doesn't work because it doesn't recognize the "tile"
Try changing the tile part to

Lua:
  local tile = Tile(toPosition)
    if tile and not tile:getHouse() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may construct this only inside a house.")
        return true
    end
Use the furniture package action that should be somewhere in TFS, or this one as an example (this one is 0.4 tho)


Lua:
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
 
Lua:
local constructionKits = {
    [3901] = 1666, [3902] = 1670, [3903] = 1652, [3904] = 1674, [3905] = 1658,
    [3906] = 3813, [3907] = 3817, [3908] = 1619, [3909] = 12799, [3910] = 2105,
    [3911] = 1614, [3912] = 3806, [3913] = 3807, [3914] = 3809, [3915] = 1716,
    [3916] = 1724, [3917] = 1732, [3918] = 1775, [3919] = 1774, [3920] = 1750,
    [3921] = 3832, [3922] = 2095, [3923] = 2098, [3924] = 2064, [3925] = 2582,
    [3926] = 2117, [3927] = 1728, [3928] = 1442, [3929] = 1446, [3930] = 1447,
    [3931] = 2034, [3932] = 2604, [3933] = 2080, [3934] = 2084, [3935] = 3821,
    [3936] = 3811, [3937] = 2101, [3938] = 3812, [5086] = 5046, [5087] = 5055,
    [5088] = 5056,
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local kit = constructionKits[item.itemid]
    if not kit then
        return false
    end

    if fromPosition.x == CONTAINER_POSITION then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Put the construction kit on the floor first.")
    elseif not Tile(fromPosition):getHouse() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may construct this only inside a house.")
    else
        item:transform(kit)
        fromPosition:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

I have this one, but the packages are something like "a package that turns into a piano" I don't know how it would be to use my beds, after all the beds are already configured.

if not Tile(fromPosition):getHouse() then?
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local BEDSINUSE = {1762, 1764, 3842, 1768, 5591, 5593,  5595,  5597,  5599,  5601}
local horizontalpos = {x = toPosition.x+1, y = toPosition.y, z = toPosition.z, stackpos = 1}
local horizontal = getThingfromPos(horizontalpos)
local verticalpos = {x = toPosition.x, y = toPosition.y+1, z = toPosition.z, stackpos = 1}
local vertical = getThingfromPos(verticalpos)

if Tile(fromPosition):getHouse() then

if item.itemid == 5603 then --bed kit
if itemEx.itemid == 1756 or itemEx.itemid == 3838 then
doTransformItem(itemEx.uid, 1760)
doTransformItem(horizontal.uid, 1761)
doRemoveItem(item.uid,1)
elseif itemEx.itemid == 3836 or itemEx.itemid == 1858 then
doTransformItem(itemEx.uid, 1754)
doTransformItem(vertical.uid, 1755)
doRemoveItem(item.uid,1)
elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Somebody is sleeping there!")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only use modification kits on empty beds.")
end
elseif item.itemid == 5604 then --hammok bed kit
if itemEx.itemid == 1760 or  itemEx.itemid == 1756 then
doTransformItem(itemEx.uid, 3838)
doTransformItem(horizontal.uid, 3839)
doRemoveItem(item.uid,1)
elseif itemEx.itemid == 1754 or itemEx.itemid == 1758 then
doTransformItem(itemEx.uid, 3836)
doTransformItem(vertical.uid, 3837)
doRemoveItem(item.uid,1)
elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Somebody is sleeping there!")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only use modification kits on empty beds.")
end
elseif item.itemid == 5605 then --cot bed kit
if itemEx.itemid == 1760 or itemEx.itemid == 3838 then
doTransformItem(itemEx.uid, 1756)
doTransformItem(horizontal.uid, 1757)
doRemoveItem(item.uid,1)
elseif itemEx.itemid == 1754 or itemEx.itemid == 3836 then
doTransformItem(itemEx.uid, 1758)
doTransformItem(vertical.uid, 1759)
doRemoveItem(item.uid,1)
elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Somebody is sleeping there!")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only use modification kits on empty beds.")
end
elseif item.itemid == 5606 then --Esse nao fiz ainda--
if itemEx.itemid == 7813 or itemEx.itemid == 7817 or itemEx.itemid == 7821 then
doTransformItem(itemEx.uid, 1760)
doTransformItem(horizontal.uid, 1761)
doRemoveItem(item.uid,1)
elseif itemEx.itemid == 7811 or itemEx.itemid == 7815 or itemEx.itemid == 7819 then
doTransformItem(itemEx.uid, 1754)
doTransformItem(vertical.uid, 1755)
doRemoveItem(item.uid,1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only use this on modified empty beds.")
end
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only use this inside a house.")
end
end
 
Lua:
local beds = {
    [7904] = {{7811, 7812}, {7813, 7814}}, -- green kit
    [7905] = {{7819, 7820}, {7821, 7822}}, -- yellow kit
    [7906] = {{7815, 7816}, {7817, 7818}}, -- red kit
    [7907] = {{1754, 1755}, {1760, 1761}}, -- removal kit
}

local function internalBedTransform(item, targetItem, toPosition, itemArray)
    targetItem:transform(itemArray[1])
    targetItem:getPosition():sendMagicEffect(CONST_ME_POFF)

    Tile(toPosition):getItemByType(ITEM_TYPE_BED):transform(itemArray[2])
    toPosition:sendMagicEffect(CONST_ME_POFF)

    item:remove()
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local newBed = beds[item:getId()]
    if not newBed or type(target) ~= "userdata" or not target:isItem() then
        return false
    end

    local tile = Tile(toPosition)
    if not tile or not tile:getHouse() then
        return false
    end

    local targetItemId = target:getId()
    if targetItemId == newBed[1][1] or targetItemId == newBed[2][1] then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You already have this bed modification.")
        return true
    end

    for _, bed in pairs(beds) do
        if bed[1][1] == targetItemId or table.contains({1758, 5502}, targetItemId) then
            toPosition:sendMagicEffect(CONST_ME_POFF)
            toPosition.y = toPosition.y + 1
            internalBedTransform(item, target, toPosition, newBed[1])
            break
        elseif bed[2][1] == targetItemId or table.contains({1756, 5500}, targetItemId) then
            toPosition:sendMagicEffect(CONST_ME_POFF)
            toPosition.x = toPosition.x + 1
            internalBedTransform(item, target, toPosition, newBed[2])
            break
        end
    end
    return true
end

 
this script doesn't work for me, I've already tested it once, so I'm using the one above. mine is 7.72 I don't know if that interferes. but it doesn't work because it doesn't recognize the "tile"
 
this script doesn't work for me, I've already tested it once, so I'm using the one above. mine is 7.72 I don't know if that interferes. but it doesn't work because it doesn't recognize the "tile"
Try changing the tile part to

Lua:
  local tile = Tile(toPosition)
    if tile and not tile:getHouse() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may construct this only inside a house.")
        return true
    end
 
Solution
Back
Top