• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 0.X remove items from x positions

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
47
Hi, i try remove items of id 2555 from X positions after i click on switch but actually my script remove switch not items form x postions :(

Code:
local locations = {
    {x = 1163, y = 883, z = 7, stackpos=1},
    {x = 1167, y = 883, z = 7, stackpos=1},
    {x = 1169, y = 883, z = 7, stackpos=1},
    {x = 1172, y = 883, z = 7, stackpos=1},
    {x = 1162, y = 885, z = 7, stackpos=1},
    {x = 1164, y = 885, z = 7, stackpos=1},
    {x = 1171, y = 885, z = 7, stackpos=1},
    {x = 1173, y = 885, z = 7, stackpos=1},
    {x = 1162, y = 887, z = 7, stackpos=1},
    {x = 1164, y = 887, z = 7, stackpos=1},
    {x = 1171, y = 887, z = 7, stackpos=1},
    {x = 1173, y = 887, z = 7, stackpos=1},
    {x = 1163, y = 889, z = 7, stackpos=1},
    {x = 1167, y = 889, z = 7, stackpos=1},
    {x = 1169, y = 889, z = 7, stackpos=1},
    {x = 1172, y = 889, z = 7, stackpos=1},
    {x = 1165, y = 891, z = 7, stackpos=1},
    {x = 1167, y = 891, z = 7, stackpos=1},
    {x = 1169, y = 891, z = 7, stackpos=1},
    {x = 1171, y = 891, z = 7, stackpos=1},
    {x = 1173, y = 891, z = 7, stackpos=1}
}
            local item = getTileItemById(locations, 2555)

function onUse(cid, item, pos)
            doRemoveItem(locations, item.uid, 1)
end
 
Solution
Now, nothing is remove but in console i have error

Code:
function onUse(cid, item, pos)
local locations = {
    {x = 1163, y = 883, z = 7, stackpos=1},
    {x = 1167, y = 883, z = 7, stackpos=1},
    {x = 1169, y = 883, z = 7, stackpos=1},
    {x = 1172, y = 883, z = 7, stackpos=1},
    {x = 1162, y = 885, z = 7, stackpos=1},
    {x = 1164, y = 885, z = 7, stackpos=1},
    {x = 1171, y = 885, z = 7, stackpos=1},
    {x = 1173, y = 885, z = 7, stackpos=1},
    {x = 1162, y = 887, z = 7, stackpos=1},
    {x = 1164, y = 887, z = 7, stackpos=1},
    {x = 1171, y = 887, z = 7, stackpos=1},
    {x = 1173, y = 887, z = 7, stackpos=1},
    {x = 1163, y = 889, z = 7, stackpos=1},
    {x = 1167, y = 889, z = 7, stackpos=1},
    {x = 1169, y =...
Which TFS are you using?

It's removing the lever because your 'local item' isn't inside of the onUse function.
By default item.uid is the item being used, in this case the lever.
 
Programming in Lua : 4.3.5
LUA:
for key, location in ipairs(locations) do
    local locationItem = getThingFromPos(location)
    if locationItem.uid > 0 then
        -- now you remove the item
    end
end

Now, nothing is remove but in console i have error

Code:
function onUse(cid, item, pos)
local locations = {
    {x = 1163, y = 883, z = 7, stackpos=1},
    {x = 1167, y = 883, z = 7, stackpos=1},
    {x = 1169, y = 883, z = 7, stackpos=1},
    {x = 1172, y = 883, z = 7, stackpos=1},
    {x = 1162, y = 885, z = 7, stackpos=1},
    {x = 1164, y = 885, z = 7, stackpos=1},
    {x = 1171, y = 885, z = 7, stackpos=1},
    {x = 1173, y = 885, z = 7, stackpos=1},
    {x = 1162, y = 887, z = 7, stackpos=1},
    {x = 1164, y = 887, z = 7, stackpos=1},
    {x = 1171, y = 887, z = 7, stackpos=1},
    {x = 1173, y = 887, z = 7, stackpos=1},
    {x = 1163, y = 889, z = 7, stackpos=1},
    {x = 1167, y = 889, z = 7, stackpos=1},
    {x = 1169, y = 889, z = 7, stackpos=1},
    {x = 1172, y = 889, z = 7, stackpos=1},
    {x = 1165, y = 891, z = 7, stackpos=1},
    {x = 1167, y = 891, z = 7, stackpos=1},
    {x = 1169, y = 891, z = 7, stackpos=1},
    {x = 1171, y = 891, z = 7, stackpos=1},
    {x = 1173, y = 891, z = 7, stackpos=1}
}
local item = getTileItemById(locations, 2555)

for key, location in ipairs(locations) do
    local locationItem = getThingFromPos(location)
    if locationItem.uid > 0 then
            doRemoveItem(locations, item.uid, 1)
    end
end
end

Code:
[20:37:52.471] [Error - Action Interface]
[20:37:52.475] data/actions/scripts/clearanvil.lua:onUse
[20:37:52.482] Description:
[20:37:52.486] (LuaInterface::luaDoRemoveItem) Item not found

Which TFS are you using?

It's removing the lever because your 'local item' isn't inside of the onUse function.
By default item.uid is the item being used, in this case the lever.

tfs 0.4 rev 3777
 
Now, nothing is remove but in console i have error

Code:
function onUse(cid, item, pos)
local locations = {
    {x = 1163, y = 883, z = 7, stackpos=1},
    {x = 1167, y = 883, z = 7, stackpos=1},
    {x = 1169, y = 883, z = 7, stackpos=1},
    {x = 1172, y = 883, z = 7, stackpos=1},
    {x = 1162, y = 885, z = 7, stackpos=1},
    {x = 1164, y = 885, z = 7, stackpos=1},
    {x = 1171, y = 885, z = 7, stackpos=1},
    {x = 1173, y = 885, z = 7, stackpos=1},
    {x = 1162, y = 887, z = 7, stackpos=1},
    {x = 1164, y = 887, z = 7, stackpos=1},
    {x = 1171, y = 887, z = 7, stackpos=1},
    {x = 1173, y = 887, z = 7, stackpos=1},
    {x = 1163, y = 889, z = 7, stackpos=1},
    {x = 1167, y = 889, z = 7, stackpos=1},
    {x = 1169, y = 889, z = 7, stackpos=1},
    {x = 1172, y = 889, z = 7, stackpos=1},
    {x = 1165, y = 891, z = 7, stackpos=1},
    {x = 1167, y = 891, z = 7, stackpos=1},
    {x = 1169, y = 891, z = 7, stackpos=1},
    {x = 1171, y = 891, z = 7, stackpos=1},
    {x = 1173, y = 891, z = 7, stackpos=1}
}
local item = getTileItemById(locations, 2555)

for key, location in ipairs(locations) do
    local locationItem = getThingFromPos(location)
    if locationItem.uid > 0 then
            doRemoveItem(locations, item.uid, 1)
    end
end
end

Code:
[20:37:52.471] [Error - Action Interface]
[20:37:52.475] data/actions/scripts/clearanvil.lua:onUse
[20:37:52.482] Description:
[20:37:52.486] (LuaInterface::luaDoRemoveItem) Item not found



tfs 0.4 rev 3777
you're using doRemoveItem incorrectly
i already gave you mostly what you need, now you just need to check if locationItem is an item and remove locationItem, not item.uid
doRemoveItem(uid, count)
it has 2 parameters ^ not 3
 
Solution
you're using doRemoveItem incorrectly
i already gave you mostly what you need, now you just need to check if locationItem is an item and remove locationItem, not item.uid
doRemoveItem(uid, count)
it has 2 parameters ^ not 3

Okay my fault :D thanks, it working
 
Back
Top