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

Lua DoRemoveItem script

Apoccalypse

New Member
Joined
Apr 15, 2017
Messages
114
Solutions
2
Reaction score
4
Hi guys,
I have a problem with my script:

LUA:
function onUse(cid, item, frompos, item2, topos)
gatepos = {x=458, y=1290, z=11, stackpos=1}
getgate = getThingfromPos(gatepos)
local storage = 12325
if item.uid == 12325 and item.itemid == 1945 then
if getPlayerStorageValue(cid, storage) == -1 then
doCreatureSay(cid,"The lever seems to be very rusty. Use the oil to move it!",TALKTYPE_ORANGE_1)
  return true
  end
 
doTransformItem(item.uid,item.itemid+1)           
doCreateItem(5771 ,1,gatepos)
doCreateItem(5772 ,1,gatepos)
doCreateItem(1284 ,1,gatepos)
doCreatureSay(cid,"The bridge has been created. Hurry up!",TALKTYPE_ORANGE_1)

elseif item.uid == 12325 and item.itemid == 1946 then
doRemoveItem(getgate.uid,1)
doRemoveItem(getgate.uid,1)
doRemoveItem(getgate.uid,1)
doTransformItem(item.uid,item.itemid-1)
end
return 1
end

So, here is a thing:
When I use the lever the script creates three items on one spot but when I use the lever again it removes only one item from the position. The console gives me an error but I have no freaking idea why it is so. The one item is removed but others two which are still there are not found. Why?
If anyone could help that would be great :)

Code:
[18:44:38.823] [Error - Action Interface]
[18:44:38.828] data/actions/scripts/Poi/dzwigniaOil.lua:onUse
[18:44:38.829] Description:
[18:44:38.829] (luaDoRemoveItem) Item not found

[18:44:38.831] [Error - Action Interface]
[18:44:38.831] data/actions/scripts/Poi/dzwigniaOil.lua:onUse
[18:44:38.831] Description:
[18:44:38.831] (luaDoRemoveItem) Item not found
 
Solution
LUA:
function onUse(cid, item, frompos, item2, topos)
    local items = {5771, 5772, 1284}
    local gatepos = {x=458, y=1290, z=11}
    local getgate = getThingfromPos(gatepos)
    local storage = 12325
    if item.uid == 12325 and item.itemid == 1945 then
        if getPlayerStorageValue(cid, storage) == -1 then
        doCreatureSay(cid,"The lever seems to be very rusty. Use the oil to move it!",TALKTYPE_ORANGE_1)
        return true
     end
        doTransformItem(item.uid,item.itemid+1)
        for i = 1, #items do
            doCreateItem(items[i], 1, gatepos)
        end
        doCreatureSay(cid,"The bridge has been created. Hurry up!",TALKTYPE_ORANGE_1)
    elseif item.uid == 12325 and item.itemid == 1946 then
        for i = 1...
LUA:
function onUse(cid, item, frompos, item2, topos)
    local items = {5771, 5772, 1284}
    local gatepos = {x=458, y=1290, z=11}
    local getgate = getThingfromPos(gatepos)
    local storage = 12325
    if item.uid == 12325 and item.itemid == 1945 then
        if getPlayerStorageValue(cid, storage) == -1 then
        doCreatureSay(cid,"The lever seems to be very rusty. Use the oil to move it!",TALKTYPE_ORANGE_1)
        return true
     end
        doTransformItem(item.uid,item.itemid+1)
        for i = 1, #items do
            doCreateItem(items[i], 1, gatepos)
        end
        doCreatureSay(cid,"The bridge has been created. Hurry up!",TALKTYPE_ORANGE_1)
    elseif item.uid == 12325 and item.itemid == 1946 then
        for i = 1, #items do
            doRemoveItem(getTileItemById(gatepos, items[i]).uid, 1)
        end
        doTransformItem(item.uid,item.itemid-1)
    end
    return 1
end
 
Solution
Back
Top