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

Lua Brigde script edit!

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
2,035
Solutions
9
Reaction score
361
Location
Chile
Hello otland , well i have this script that it's for create a brigde
but i want it to Remove brigde and then that it would be created again
so the same script in reverse....
here it's the original one

Code:
-- by Nottinghster

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local posTel = {x=32630, y=31699, z=10}
    local posBridge = {
        [1] = {x=32628, y=31699, z=10},
        [2] = {x=32629, y=31699, z=10}
        }
    local switches = {
        [1] = {x=32625, y=31698, z=11},
        [2] = {x=32620, y=31687, z=11}
        }
      
    if item.itemid == 1945 then
        doCreateItem(1284,posBridge[1])
        doCreateItem(1284,posBridge[2])
        for i=1,#switches do
            if switches[i].x == fromPosition.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
        doTransformItem(item.uid,item.itemid+1)
        doTransformItem(getTileItemById(switches[b],1945).uid,1946)
    elseif item.itemid == 1946 then
        for p = 1,#posBridge do
            doRelocate(posBridge[p], posTel)
        end
        for z = 1,#posBridge do
            posBridge[z].stackpos = 1
            if getThingfromPos(posBridge[z]).itemid > 1000 then
                doRemoveItem(getThingfromPos(posBridge[z]).uid)
            end
        end  
        for i=1,#switches do
            if switches[i].x == toPosition.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
        doCreateItem(493,posBridge[1])
        doCreateItem(493,posBridge[2])
        doCreateItem(4799,posBridge[1])
        doCreateItem(4797,posBridge[2])  
        doTransformItem(item.uid,item.itemid-1)
        doTransformItem(getTileItemById(switches[b],1946).uid,1945)
    end
  
    return true
end

so i changed the doCreateItem for DoRemoveItem functions
but it doesnt works
Code:
-- by Nottinghster

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local posTel = {x=32630, y=31699, z=10}
    local posBridge = {
        [1] = {x=32628, y=31699, z=10},
        [2] = {x=32629, y=31699, z=10}
        }
    local switches = {
        [1] = {x=32625, y=31698, z=11},
        [2] = {x=32620, y=31687, z=11}
        }

        if item.itemid == 1945 then
        for p = 1,#posBridge do
            doRelocate(posBridge[p], posTel)
        end
        for z = 1,#posBridge do
            posBridge[z].stackpos = 1
            if getThingfromPos(posBridge[z]).itemid > 1000 then
                doRemoveItem(getThingfromPos(posBridge[z]).uid)
            end
        end  
        for i=1,#switches do
            if switches[i].x == toPosition.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
        doTransformItem(item.uid,item.itemid+1)
        doTransformItem(getTileItemById(switches[b],1945).uid,1946)
    elseif item.itemid == 1946 then
        doCreateItem(1284,posBridge[1])
        doCreateItem(1284,posBridge[2])
        for i=1,#switches do
            if switches[i].x == fromPosition.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
        doCreateItem(493,posBridge[1])
        doCreateItem(493,posBridge[2])
        doCreateItem(4799,posBridge[1])
        doCreateItem(4797,posBridge[2])  
        doTransformItem(item.uid,item.itemid-1)
        doTransformItem(getTileItemById(switches[b],1946).uid,1945)
    end
  
    return true
end

also i tried to invert scripts
but neither works

Code:
-- by Nottinghster

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local posTel = {x=32630, y=31699, z=10}
    local posBridge = {
        [1] = {x=32628, y=31699, z=10},
        [2] = {x=32629, y=31699, z=10}
        }
    local switches = {
        [1] = {x=32625, y=31698, z=11},
        [2] = {x=32620, y=31687, z=11}
        }
       
    if item.itemid == 1946 then
        for p = 1,#posBridge do
            doRelocate(posBridge[p], posTel)
        end
        for z = 1,#posBridge do
            posBridge[z].stackpos = 1
            if getThingfromPos(posBridge[z]).itemid > 1000 then
                doCreateItem(getThingfromPos(posBridge[z]).uid)
            end
        end   
        for i=1,#switches do
            if switches[i].x == toPosition.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
        doTransformItem(item.uid,item.itemid+1)
        doTransformItem(getTileItemById(switches[b],1945).uid,1946)

        elseif item.itemid == 1945 then
        doRemoveItem(1284,posBridge[1])
        doRemoveItem(1284,posBridge[2])
        for i=1,#switches do
            if switches[i].x == fromPosition.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
        doCreateItem(493,posBridge[1])
        doCreateItem(493,posBridge[2])
        doCreateItem(4799,posBridge[1])
        doCreateItem(4797,posBridge[2])   
        doTransformItem(item.uid,item.itemid-1)
        doTransformItem(getTileItemById(switches[b],1946).uid,1945)
    end
   
    return true
end




what more should be change? i would appreciate your help
 
Back
Top