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

Solved Error onUse if item inside backpack

Shackal

Alien Project
Joined
Feb 7, 2009
Messages
211
Reaction score
17
Location
Brazil
Add it right under function onUse, so also above local groundTile.
You can add an extra if statement with "if toPosition.x ~= CONTAINER_POSITION then", so all code is inside that or do this.
Code:
if toPosition.x == CONTAINER_POSITION then
     return doPlayerSendCancel(cid, "Sorry, not possible.")
end

Good afternoon people

TFS 0.4
I found a critical bug, apparently common in TFS 8.6.
If you use Squeezing Gear on any item inside your backpack, returns the following error in the distro:

pOmFz5P.png


Placing the ElfBot to use this item every 20 milliseconds, the server drops.

my squeezinggear.lua
Code:
local holes = {468, 481, 483, 7932}
local holeId = {294, 369, 370, 383, 392, 408, 409, 427, 428, 430, 462, 469, 470, 482, 484, 485, 489, 924, 3135, 3136}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local groundTile = getThingfromPos(toPosition)
    if isInArray(holes, itemEx.itemid) then
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 2739 then
        doTransformItem(itemEx.uid, 2737)
        doCreateItem(2694, 1, toPosition)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 2782 then
        doTransformItem(itemEx.uid, 2781)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 1499 then
        doRemoveItem(itemEx.uid)
    elseif (itemEx.uid <= 65535 or itemEx.actionid > 0) and (itemEx.itemid == 355 or itemEx.itemid == 9025) then
        doTransformItem(itemEx.uid, 392)
        doDecayItem(itemEx.uid)
    elseif groundTile.itemid == 384 or groundTile.itemid == 418 or groundTile.itemid == 8278 then
        doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z - 1}, FALSE)
    elseif isInArray(holeId, itemEx.itemid) then
        local hole = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
        if hole.itemid > 0 then
            doTeleportThing(hole.uid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, FALSE)
        else
            doPlayerSendCancel(cid, "Sorry, not possible.")
        end
    else
        return false
    end
    return true
end

Ty in advance!!
 
Last edited:
adding this condition in the script, the distro returned the same error
Code:
elseif toPosition.x ~= CONTAINER_POSITION then
        return false
 
If you add return false under it change ~= to ==, since else it will only continue if the item is in a container.
 
This also does not work
Code:
local holes = {468, 481, 483, 7932}
local holeId = {294, 369, 370, 383, 392, 408, 409, 427, 428, 430, 462, 469, 470, 482, 484, 485, 489, 924, 3135, 3136}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local groundTile = getThingfromPos(toPosition)
    if toPosition.x ~= CONTAINER_POSITION then
        if isInArray(holes, itemEx.itemid) then
            doTransformItem(itemEx.uid, itemEx.itemid + 1)
            doDecayItem(itemEx.uid)
        elseif itemEx.itemid == 2739 then
            doTransformItem(itemEx.uid, 2737)
            doCreateItem(2694, 1, toPosition)
            doDecayItem(itemEx.uid)
        elseif itemEx.itemid == 2782 then
            doTransformItem(itemEx.uid, 2781)
            doDecayItem(itemEx.uid)
        elseif itemEx.itemid == 1499 then
            doRemoveItem(itemEx.uid)
        elseif (itemEx.uid <= 65535 or itemEx.actionid > 0) and (itemEx.itemid == 355 or itemEx.itemid == 9025) then
            doTransformItem(itemEx.uid, 392)
            doDecayItem(itemEx.uid)
        elseif groundTile.itemid == 384 or groundTile.itemid == 418 or groundTile.itemid == 8278 then
            doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z - 1}, FALSE)
        elseif isInArray(holeId, itemEx.itemid) then
            local hole = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
            if hole.itemid > 0 then
                doTeleportThing(hole.uid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, FALSE)
            else
                doPlayerSendCancel(cid, "Sorry, not possible.")
            end
        else
            return false
        end
    end
    return true
end
 
like this nothing too
Code:
local holes = {468, 481, 483, 7932}
local holeId = {294, 369, 370, 383, 392, 408, 409, 427, 428, 430, 462, 469, 470, 482, 484, 485, 489, 924, 3135, 3136}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local groundTile = getThingfromPos(toPosition)
    if isInArray(holes, itemEx.itemid) then
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 2739 then
        doTransformItem(itemEx.uid, 2737)
        doCreateItem(2694, 1, toPosition)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 2782 then
        doTransformItem(itemEx.uid, 2781)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 1499 then
        doRemoveItem(itemEx.uid)
    elseif (itemEx.uid <= 65535 or itemEx.actionid > 0) and (itemEx.itemid == 355 or itemEx.itemid == 9025) then
        doTransformItem(itemEx.uid, 392)
        doDecayItem(itemEx.uid)
    elseif groundTile.itemid == 384 or groundTile.itemid == 418 or groundTile.itemid == 8278 then
        doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z - 1}, FALSE)
    elseif isInArray(holeId, itemEx.itemid) then
        local hole = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
        if hole.itemid > 0 then
            doTeleportThing(hole.uid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, FALSE)
        else
            doPlayerSendCancel(cid, "Sorry, not possible.")
        end
    elseif toPosition.x == CONTAINER_POSITION then
        return false
    else
        return false
    end
    return true
end
 
Add it right under function onUse. It reads the code from the top to the bottom, so what is added higher in the function will be loaded/executed first.
 
Thus recognizes the action, put as a test to send a message in this condition (toPosition.x == CONTAINER_POSITION) at the beginning of the script and it worked, but the error in the distro is still

sorry my bad english bro

Code:
local holes = {468, 481, 483, 7932}
local holeId = {294, 369, 370, 383, 392, 408, 409, 427, 428, 430, 462, 469, 470, 482, 484, 485, 489, 924, 3135, 3136}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local groundTile = getThingfromPos(toPosition)
    if toPosition.x == CONTAINER_POSITION then
        doPlayerSendCancel(cid, "Sorry, not possible.")
    elseif isInArray(holes, itemEx.itemid) then
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 2739 then
        doTransformItem(itemEx.uid, 2737)
        doCreateItem(2694, 1, toPosition)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 2782 then
        doTransformItem(itemEx.uid, 2781)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 1499 then
        doRemoveItem(itemEx.uid)
    elseif (itemEx.uid <= 65535 or itemEx.actionid > 0) and (itemEx.itemid == 355 or itemEx.itemid == 9025) then
        doTransformItem(itemEx.uid, 392)
        doDecayItem(itemEx.uid)
    elseif groundTile.itemid == 384 or groundTile.itemid == 418 or groundTile.itemid == 8278 then
        doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z - 1}, FALSE)
    elseif isInArray(holeId, itemEx.itemid) then
        local hole = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
        if hole.itemid > 0 then
            doTeleportThing(hole.uid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, FALSE)
        else
            doPlayerSendCancel(cid, "Sorry, not possible.")
        end
    else
        return false
    end
    return true
end
 
Code:
local holes = {468, 481, 483, 7932}
local holeId = {294, 369, 370, 383, 392, 408, 409, 427, 428, 430, 462, 469, 470, 482, 484, 485, 489, 924, 3135, 3136}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local groundTile = getThingfromPos(toPosition)
    if toPosition.x == CONTAINER_POSITION then
        doPlayerSendCancel(cid, "Sorry, not possible.")
    elseif isInArray(holes, itemEx.itemid) then
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 2739 then
        doTransformItem(itemEx.uid, 2737)
        doCreateItem(2694, 1, toPosition)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 2782 then
        doTransformItem(itemEx.uid, 2781)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 1499 then
        doRemoveItem(itemEx.uid)
    elseif (itemEx.uid <= 65535 or itemEx.actionid > 0) and (itemEx.itemid == 355 or itemEx.itemid == 9025) then
        doTransformItem(itemEx.uid, 392)
        doDecayItem(itemEx.uid)
    elseif groundTile.itemid == 384 or groundTile.itemid == 418 or groundTile.itemid == 8278 then
        doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z - 1}, FALSE)
    elseif isInArray(holeId, itemEx.itemid) then
        local hole = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
        if hole.itemid > 0 then
            doTeleportThing(hole.uid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, FALSE)
        else
            doPlayerSendCancel(cid, "Sorry, not possible.")
        end
    else
        return false
    end
    return true
end
 
Add it right under function onUse, so also above local groundTile.
You can add an extra if statement with "if toPosition.x ~= CONTAINER_POSITION then", so all code is inside that or do this.
Code:
if toPosition.x == CONTAINER_POSITION then
     return doPlayerSendCancel(cid, "Sorry, not possible.")
end
 
Back
Top