• 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 [OTHIRE] Problem with few scripts

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
2,035
Solutions
9
Reaction score
357
Location
Chile
Hello otland

Well im stuck with an script that creates a brigde made of 4 sqm

X4ARfCI.png

The thing is that the script works only once when i pull the lever the brigde appears but when i pull the lever again nothing happens i've tried several scripts and none of them besides this works

Code:
local poss = {
[1] = {x=32410, y=32231, z=10},
[2] = {x=32410, y=32232, z=10},
[3] = {x=32411, y=32231, z=10},
[4] = {x=32411, y=32232, z=10}
}

local lever = {
[1] = {x=32412, y=32231, z=10, stackpos = 1},
[2] = {x=32412, y=32232, z=10,stackpos = 1 }

}
function onUse(cid, item, fromPosition, target, toPosition)
    local way = (item.itemid == 1945)
    for i = 1, #lever do
        local lev = getTileItemById(lever[i], item.itemid)
        if lev and lev.uid > 0 then
            doTransformItem(lev.uid, (lev.itemid == 1945 and 1946 or 1945))
        end
    end
    if way then
        for i = 3, 4 do
            if getTileItemById(poss[i], 4799).itemid > 0 then
                doRemoveItem(getTileItemById(poss[i], 4799).uid)
            end
        end
        for i = 1, #poss do
            if getTileItemById(poss[i], 493).itemid > 0 then
                doCreateItem(1284, 1, poss[i])
            end
        end
    else
        for i = 1, #poss do
            if getTileItemById(poss[i], 1284).itemid > 0 then
                doCreateItem(493, 1, poss[i])
            end
        end
        for i = 3, 4 do
            if getTileItemById(poss[i], 4799).itemid == 0 then
                doCreateItem(4799, 1, poss[i])
            end
        end
    end
    return true
end

Code:
<action actionid="4022" script="tibia/bonelord_brigde_4sqm.lua" />
i've tried with these scripts too and few others also i've edited other ones buyt whitout triumph
[Release] Bridge Lever
Solved - Lever Bridge Help
can anyone edit this for me or tell me what it's wrong here?


And the issue with this other script is that works 90% fine but i need if a player it standing on the square where the changes will happen the lever would not be able to be pulled, because it bug the server
Code:
function onUse(cid, item, frompos, item2, topos)
    tile1 = {x = 32225, y = 32276, z = 8, stackpos = 1}
    gettile1 = getThingfromPos(tile1)
    if item.actionid == 4016 and item.itemid == 1945 then
        doRemoveItem(gettile1.uid,1)
        doCreateItem(427,1,tile1)   
        doTransformItem(item.uid,item.itemid+1)
    elseif item.actionid == 4016 and item.itemid == 1946 then
        doRemoveItem(gettile1.uid,1)
        doCreateItem(351,1,tile1)
        doTransformItem(item.uid,item.itemid-1)       
    else
        doPlayerSendCancel(cid,"Sorry, not possible.")
    end
    return 1
end
Code:
<action actionid="4016" script="tibia/Thais Lighthouse Quest/switch.lua" />

thanks in advance and regards to everyone
@Xikini @Sarah Wesker @Nottinghster

anyone of you guys can re-edit this or guide me please?
thanks again in advance
 
Solution
X
wtf. I literally explained how to script this step by step.
How you guys managed to turn 20 lines of code into 70 is a remarkable feat I don't even want to try to figure out.

Try this.
and ENSURE YOUR POSITIONS ARE CORRECT.
The entire script will break if you do the positions incorrectly.
F96VXaE.png

LUA:
local items = {
    mud_border = 4799,
    water = 493,
    bridge = 1284
}
local bridge_positions = {
    {x = 1111, y = 1111, z = 7},
    {x = 2222, y = 1111, z = 7},
    {x = 3333, y = 2222, z = 7},
    {x = 4444, y = 2222, z = 7}
}
local relocate_position = {x = 5555, y = 3333, z = 7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getTileItemById(bridge_positions[1], items.water).uid ~=...
what about this?
Rook switch error
btw. do not add people to the thread if they do not want to.
thanks i will keep it in mind in a future anyway im sure that this wouldn't annoy to these guys it's just a notification
regarding the rook switch doesn't work i have a rook script i tried to edit it but didn't worked i don't know pretty well how to do it anyway at least with "ADVANCED" scripts
thanks men
 
thanks in advance and regards to everyone
Xikini Sarah Wesker Nottinghster

anyone of you guys can re-edit this or guide me please?
thanks again in advance
I choose to guide.

All of your problems can be fixed with simple logic.

What do I want the script to do?
-> Perform the same actions as real tibia.

What does the script do in real tibia?
-> In real tibia there are two levers.
-> Both levers do the same actions.
-> Function 1) Add a bridge
-> Function 2) Remove the bridge and move all objects & players to the right side of the bridge.
-> Functions 1 & 2 only happen on the left or right triggerings, and both levers flop independantly.


Great. So how would the script work?

Well, since the levers flop independantly, we will need to check if the bridge is 'up' or 'down'.
-> We can check for the ID of the bridge on any of the 4 tiles to determine this.
LUA:
function onUse(blah1, blah2, blah3, blah4, blah5)
    if bridge is down then
        -- script here
    elseif bridge is up then
        -- more script here
    end
    return true
end

Alright, since that is easy to check we can also check if the lever would do anything when we flop it.
Since we want to flop the lever irregardless of what happens, we will put the lever flopping outside of the checks.
-> If lever is currently left, and bridge is down, do something.
-> If lever is currently right, and bridge is up, do something.
LUA:
function onUse(blah1, blah2, blah3, blah4, blah5)
    if bridge is down and lever left then
        -- bring bridge up.
    elseif bridge is up and lever right then
        -- bring bridge down.
    end
    -- flop lever
    return true
end

Alright, now that we have determined that something should be happening, we can start doing the cool shit.

Let's start by creating the bridge.

Since we can't be sure if the bridge will go over or under the mud border, and we can't be sure it will overtake the water when we 'add' the item to that position instead of 'blooping' into the water, we are left with only one definitive option, we need to transform the water into bridge tiles.
-> Remove the borders
-> Transform the water into bridge tiles.
-> Flop the lever used.
LUA:
function onUse(blah1, blah2, blah3, blah4, blah5)
    if bridge is down and lever left then
        -- Remove the borders
        -- Transform the water into bridge tiles.
    elseif bridge is up and lever right then
        -- bring bridge down.
    end
    -- flop lever
    return true
end

Alright Done.

Now that we know what the bridge looks like when it's up, we can take it down.
As before, we can't be sure that the water won't 'bloop' the borders, so we will need to add them first, then tranform the bridge into water.
But before we can do that, we will want to move all items/objects/players/creatures on the bridge tiles to their new home.
The easiest method to move a large amount of objects is the 'doRelocate' function, however this might not be available on all servers, So..
-> 'doRelocate' the 4 tiles to their new home
or
-> search tiles above stackpos 0 for items, and teleport them to their new home
then
-> add mud borders
-> transform bridge into water
LUA:
function onUse(blah1, blah2, blah3, blah4, blah5)
    if bridge is down and lever left then
        -- Remove the borders
        -- Transform the water into bridge tiles.
    elseif bridge is up and lever right then
        --[[
      
        -- 'doRelocate' the 4 tiles to their new home
        or
        -- search tiles above stackpos 0 for items, and teleport them to their new home
          
        ]]--
      
        -- add mud borders
        -- transform bridges into water
    end
    -- flop lever
    return true
end

and bam, this should be a working script.
Just put in the functions.
 
I choose to guide.

All of your problems can be fixed with simple logic.

What do I want the script to do?
-> Perform the same actions as real tibia.

What does the script do in real tibia?
-> In real tibia there are two levers.
-> Both levers do the same actions.
-> Function 1) Add a bridge
-> Function 2) Remove the bridge and move all objects & players to the right side of the bridge.
-> Functions 1 & 2 only happen on the left or right triggerings, and both levers flop independantly.


Great. So how would the script work?

Well, since the levers flop independantly, we will need to check if the bridge is 'up' or 'down'.
-> We can check for the ID of the bridge on any of the 4 tiles to determine this.
LUA:
function onUse(blah1, blah2, blah3, blah4, blah5)
    if bridge is down then
        -- script here
    elseif bridge is up then
        -- more script here
    end
    return true
end

Alright, since that is easy to check we can also check if the lever would do anything when we flop it.
Since we want to flop the lever irregardless of what happens, we will put the lever flopping outside of the checks.
-> If lever is currently left, and bridge is down, do something.
-> If lever is currently right, and bridge is up, do something.
LUA:
function onUse(blah1, blah2, blah3, blah4, blah5)
    if bridge is down and lever left then
        -- bring bridge up.
    elseif bridge is up and lever right then
        -- bring bridge down.
    end
    -- flop lever
    return true
end

Alright, now that we have determined that something should be happening, we can start doing the cool shit.

Let's start by creating the bridge.

Since we can't be sure if the bridge will go over or under the mud border, and we can't be sure it will overtake the water when we 'add' the item to that position instead of 'blooping' into the water, we are left with only one definitive option, we need to transform the water into bridge tiles.
-> Remove the borders
-> Transform the water into bridge tiles.
-> Flop the lever used.
LUA:
function onUse(blah1, blah2, blah3, blah4, blah5)
    if bridge is down and lever left then
        -- Remove the borders
        -- Transform the water into bridge tiles.
    elseif bridge is up and lever right then
        -- bring bridge down.
    end
    -- flop lever
    return true
end

Alright Done.

Now that we know what the bridge looks like when it's up, we can take it down.
As before, we can't be sure that the water won't 'bloop' the borders, so we will need to add them first, then tranform the bridge into water.
But before we can do that, we will want to move all items/objects/players/creatures on the bridge tiles to their new home.
The easiest method to move a large amount of objects is the 'doRelocate' function, however this might not be available on all servers, So..
-> 'doRelocate' the 4 tiles to their new home
or
-> search tiles above stackpos 0 for items, and teleport them to their new home
then
-> add mud borders
-> transform bridge into water
LUA:
function onUse(blah1, blah2, blah3, blah4, blah5)
    if bridge is down and lever left then
        -- Remove the borders
        -- Transform the water into bridge tiles.
    elseif bridge is up and lever right then
        --[[
     
        -- 'doRelocate' the 4 tiles to their new home
        or
        -- search tiles above stackpos 0 for items, and teleport them to their new home
         
        ]]--
     
        -- add mud borders
        -- transform bridges into water
    end
    -- flop lever
    return true
end

and bam, this should be a working script.
Just put in the functions.
Thanks a Lot mate i'm going to tedt this tomorrow
 
Hello otland

Well im stuck with an script that creates a brigde made of 4 sqm

X4ARfCI.png

The thing is that the script works only once when i pull the lever the brigde appears but when i pull the lever again nothing happens i've tried several scripts and none of them besides this works

Code:
local poss = {
[1] = {x=32410, y=32231, z=10},
[2] = {x=32410, y=32232, z=10},
[3] = {x=32411, y=32231, z=10},
[4] = {x=32411, y=32232, z=10}
}

local lever = {
[1] = {x=32412, y=32231, z=10, stackpos = 1},
[2] = {x=32412, y=32232, z=10,stackpos = 1 }

}
function onUse(cid, item, fromPosition, target, toPosition)
    local way = (item.itemid == 1945)
    for i = 1, #lever do
        local lev = getTileItemById(lever[i], item.itemid)
        if lev and lev.uid > 0 then
            doTransformItem(lev.uid, (lev.itemid == 1945 and 1946 or 1945))
        end
    end
    if way then
        for i = 3, 4 do
            if getTileItemById(poss[i], 4799).itemid > 0 then
                doRemoveItem(getTileItemById(poss[i], 4799).uid)
            end
        end
        for i = 1, #poss do
            if getTileItemById(poss[i], 493).itemid > 0 then
                doCreateItem(1284, 1, poss[i])
            end
        end
    else
        for i = 1, #poss do
            if getTileItemById(poss[i], 1284).itemid > 0 then
                doCreateItem(493, 1, poss[i])
            end
        end
        for i = 3, 4 do
            if getTileItemById(poss[i], 4799).itemid == 0 then
                doCreateItem(4799, 1, poss[i])
            end
        end
    end
    return true
end

Code:
<action actionid="4022" script="tibia/bonelord_brigde_4sqm.lua" />
i've tried with these scripts too and few others also i've edited other ones buyt whitout triumph
[Release] Bridge Lever
Solved - Lever Bridge Help
can anyone edit this for me or tell me what it's wrong here?


And the issue with this other script is that works 90% fine but i need if a player it standing on the square where the changes will happen the lever would not be able to be pulled, because it bug the server
Code:
function onUse(cid, item, frompos, item2, topos)
    tile1 = {x = 32225, y = 32276, z = 8, stackpos = 1}
    gettile1 = getThingfromPos(tile1)
    if item.actionid == 4016 and item.itemid == 1945 then
        doRemoveItem(gettile1.uid,1)
        doCreateItem(427,1,tile1)
        doTransformItem(item.uid,item.itemid+1)
    elseif item.actionid == 4016 and item.itemid == 1946 then
        doRemoveItem(gettile1.uid,1)
        doCreateItem(351,1,tile1)
        doTransformItem(item.uid,item.itemid-1)   
    else
        doPlayerSendCancel(cid,"Sorry, not possible.")
    end
    return 1
end
Code:
<action actionid="4016" script="tibia/Thais Lighthouse Quest/switch.lua" />

thanks in advance and regards to everyone
@Xikini @Sarah Wesker @Nottinghster

anyone of you guys can re-edit this or guide me please?

thanks again in advance

Feel free to ask any questions if you find any errors ;)
I've already included your coords and IDs (water, border and bridge).

The pos_realocar is in case if have any monsters or items on top of the bridge, it will be teleported to coords defined in script

LUA:
local pos_realocar = {x = 32410, y = 32230, z = 10}

local pos_ponte = {
[1] = {x = 32410, y = 32231, z = 10},
[2] = {x = 32410, y = 32232, z = 10},
[3] = {x = 32411, y = 32231, z = 10},
[4] = {x = 32411, y = 32232, z = 10}
}

local alavancas = {
[1] = {x = 32412, y = 32231, z = 10},
[2] = {x = 32412, y = 32232, z = 10}
}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 1946 then
    for p = 1, #pos_ponte do
            doRelocate(pos_ponte[p], pos_realocar)
        end
    for z = 1, #pos_ponte do
        pos_ponte[z].stackpos = 1
            if getThingfromPos(pos_ponte[z]).itemid > 1000 and getThingfromPos(pos_ponte[z]).itemid ~= 4645 and getThingfromPos(pos_ponte[z]).itemid ~= 4647 then
                doRemoveItem(getThingfromPos(pos_ponte[z]).uid)
            end
        end            
        for i=1,#alavancas do
            if alavancas[i].x == frompos.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
        doCreateItem(1284, pos_ponte[1]) -- Bridge
        doCreateItem(1284, pos_ponte[2]) -- Bridge
        doCreateItem(1284, pos_ponte[3]) -- Bridge
        doCreateItem(1284, pos_ponte[4]) -- Bridge
        doTransformItem(item.uid, item.itemid - 1)
        doTransformItem(getTileItemById(alavancas[b], 1946).uid, 1945)
    elseif item.itemid == 1945 then
        for z = 1,#pos_ponte do
            pos_ponte[z].stackpos = 1
            if getThingfromPos(pos_ponte[z]).itemid > 1000 then
                doRemoveItem(getThingfromPos(pos_ponte[z]).uid)
            end
        end
        for i=1,#alavancas do
            if alavancas[i].x == topos.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
    doCreateItem(4799, pos_ponte[1]) -- Border
    doCreateItem(493, pos_ponte[2]) -- Water
    doCreateItem(4799, pos_ponte[3]) -- Border
    doCreateItem(493, pos_ponte[4]) -- Water
        doTransformItem(item.uid, item.itemid + 1)
        doTransformItem(getTileItemById(alavancas[b], 1945).uid, 1946)
    end
    return true
end
 
Last edited:
Feel free to ask any questions if you find any errors ;)
I've already included your coords and IDs (water, border and bridge).

The pos_realocar is in case if have any monsters or items on top of the bridge, it will be teleported to coords defined in script

LUA:
local pos_realocar = {x = 32410, y = 32230, z = 10}

local pos_ponte = {
[1] = {x = 32410, y = 32231, z = 10},
[2] = {x = 32410, y = 32232, z = 10},
[3] = {x = 32411, y = 32231, z = 10},
[4] = {x = 32411, y = 32232, z = 10}
}

local alavancas = {
[1] = {x = 32412, y = 32231, z = 10},
[2] = {x = 32412, y = 32232, z = 10}
}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 1946 then
    for p = 1, #pos_ponte do
            doRelocate(pos_ponte[p], pos_realocar)
        end
    for z = 1, #pos_ponte do
        pos_ponte[z].stackpos = 1
            if getThingfromPos(pos_ponte[z]).itemid > 1000 and getThingfromPos(pos_ponte[z]).itemid ~= 4645 and getThingfromPos(pos_ponte[z]).itemid ~= 4647 then
                doRemoveItem(getThingfromPos(pos_ponte[z]).uid)
            end
        end           
        for i=1,#alavancas do
            if alavancas[i].x == frompos.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
        doCreateItem(1284, pos_ponte[1]) -- Bridge
        doCreateItem(1284, pos_ponte[2]) -- Bridge
        doCreateItem(1284, pos_ponte[3]) -- Bridge
        doCreateItem(1284, pos_ponte[4]) -- Bridge
        doTransformItem(item.uid, item.itemid - 1)
        doTransformItem(getTileItemById(alavancas[b], 1946).uid, 1945)
    elseif item.itemid == 1945 then
        for z = 1,#pos_ponte do
            pos_ponte[z].stackpos = 1
            if getThingfromPos(pos_ponte[z]).itemid > 1000 then
                doRemoveItem(getThingfromPos(pos_ponte[z]).uid)
            end
        end
        for i=1,#alavancas do
            if alavancas[i].x == topos.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
    doCreateItem(4799, pos_ponte[1]) -- Border
    doCreateItem(493, pos_ponte[2]) -- Water
    doCreateItem(4799, pos_ponte[3]) -- Border
    doCreateItem(493, pos_ponte[4]) -- Water
        doTransformItem(item.uid, item.itemid + 1)
        doTransformItem(getTileItemById(alavancas[b], 1945).uid, 1946)
    end
    return true
end
I'm gonna test thanks you a Lot @Nottinghster *:
 
@Nottinghster
bro it worked but weird i tried to edit coordinates and the items id places but i can't manage to make it work properly
first whitout using the lever
the map look like this(whitout use the lever it the begin)
X4ARfCI.png

then first use of lever(when brigde should appear)
bBdv9sj.png

seccond use of lever(when should dissapear)
qY8pXPF.png

third use of the lever(when should re-appear)
vimbI7d.png


and i get this in console exe
Code:
data/actions/scripts/tibia/lever_thais_beholder.lua:onUse

LuaScriptInterface::luaDoTransformItem(). Item not found

Lua Script Error: [Action Interface]
data/actions/scripts/tibia/lever_thais_beholder.lua:onUse

LuaScriptInterface::luaDoTransformItem(). Item not found

Lua Script Error: [Action Interface]
data/actions/scripts/tibia/lever_thais_beholder.lua:onUse

LuaScriptInterface::luaDoTransformItem(). Item not found

Lua Script Error: [Action Interface]
data/actions/scripts/tibia/lever_thais_beholder.lua:onUse

LuaScriptInterface::luaDoTransformItem(). Item not found

pls help x.x
 
i will give this a try xD
add before local alavancas
Code:
local pos_replacement = {
[1] = {x = xxxx, y = xxxx, z = xxxx},
[2] = {x = xxxx, y = xxxx, z = xxxx},
[3] = {x = xxxx, y = xxxx, z = xxxx},
[4] = {x = xxxx, y = xxxx, z = xxxx}
}

then change this
Code:
 doCreateItem(4799, pos_ponte[1]) -- Border
    doCreateItem(493, pos_ponte[2]) -- Water
    doCreateItem(4799, pos_ponte[3]) -- Border
    doCreateItem(493, pos_ponte[4]) -- Water

to this:
Code:
  doCreateItem(4799, pos_replacement[1]) -- Border
    doCreateItem(493, pos_replacement[2]) -- Water
    doCreateItem(4799, pos_replacement[3]) -- Border
    doCreateItem(493, pos_replacement[4]) -- Water

and then add coordinates according to Xikini's logic
Xikini said:
-> Remove the borders
-> Transform the water into bridge tiles.

in this case u should place Border in the correct place of "replacement", same as Water.
 
Last edited:
i will give this a try xD
add before local alavancas
Code:
local pos_replacement = {
[1] = {x = xxxx, y = xxxx, z = xxxx},
[2] = {x = xxxx, y = xxxx, z = xxxx},
[3] = {x = xxxx, y = xxxx, z = xxxx},
[4] = {x = xxxx, y = xxxx, z = xxxx}
}

then change this
Code:
 doCreateItem(4799, pos_ponte[1]) -- Border
    doCreateItem(493, pos_ponte[2]) -- Water
    doCreateItem(4799, pos_ponte[3]) -- Border
    doCreateItem(493, pos_ponte[4]) -- Water

to this:
Code:
  doCreateItem(4799, pos_replacement[1]) -- Border
    doCreateItem(493, pos_replacement[2]) -- Water
    doCreateItem(4799, pos_replacement[3]) -- Border
    doCreateItem(493, pos_replacement[4]) -- Water

and then add coordinates according to Xikini's logic


in this case u should place Border in the correct place of "replacement", same as Water.


thanks for your reply mate, look now the scripts looks like this
and works better, at the first usage of the lever the brigde is created.
qY8pXPF.png


Code:
local pos_realocar = {x = 32410, y = 32230, z = 10}
local pos_ponte = {
[1] = {x = 32410, y = 32231, z = 10},
[2] = {x = 32410, y = 32232, z = 10},
[3] = {x = 32411, y = 32231, z = 10},
[4] = {x = 32411, y = 32232, z = 10}
}
local pos_replacement = {
[1] = {x = 32410, y = 32231, z = 10},
[2] = {x = 32410, y = 32232, z = 10},
[3] = {x = 32411, y = 32231, z = 10},
[4] = {x = 32411, y = 32232, z = 10}
}

local alavancas = {
[1] = {x = 32412, y = 32231, z = 10},
[2] = {x = 32412, y = 32232, z = 10}
}
function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 1946 then
    for p = 1, #pos_ponte do
            doRelocate(pos_ponte[p], pos_realocar)
        end
    for z = 1, #pos_ponte do
        pos_ponte[z].stackpos = 1
            if getThingfromPos(pos_ponte[z]).itemid > 1000 and getThingfromPos(pos_ponte[z]).itemid ~= 4645 and getThingfromPos(pos_ponte[z]).itemid ~= 4647 then
                doRemoveItem(getThingfromPos(pos_ponte[z]).uid)
            end
        end          
        for i=1,#alavancas do
            if alavancas[i].x == frompos.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
        doCreateItem(1284, pos_ponte[1]) -- Bridge
        doCreateItem(1284, pos_ponte[2]) -- Bridge
        doCreateItem(1284, pos_ponte[3]) -- Bridge
        doCreateItem(1284, pos_ponte[4]) -- Bridge
        doTransformItem(item.uid, item.itemid - 1)
        doTransformItem(getTileItemById(alavancas[b], 1946).uid, 1945)
    elseif item.itemid == 1945 then
        for z = 1,#pos_ponte do
            pos_ponte[z].stackpos = 1
            if getThingfromPos(pos_ponte[z]).itemid > 1000 then
                doRemoveItem(getThingfromPos(pos_ponte[z]).uid)
            end
        end
        for i=1,#alavancas do
            if alavancas[i].x == topos.x then
                o = i
            end
        end
        if o == 1 then
            b = 2
        else
            b = 1
        end
   doCreateItem(4799, pos_ponte[1]) -- Border
    doCreateItem(493, pos_ponte[2]) -- Water
    doCreateItem(4799, pos_ponte[3]) -- Border
    doCreateItem(493, pos_ponte[4]) -- Water
        doTransformItem(item.uid, item.itemid + 1)
        doTransformItem(getTileItemById(alavancas[b], 1945).uid, 1946)
    end
    return true
end
but at the seccond usage (when brigde should be replaced by the water and borders looks like this)
vimbI7d.png


please Help ! :c
 
wtf. I literally explained how to script this step by step.
How you guys managed to turn 20 lines of code into 70 is a remarkable feat I don't even want to try to figure out.

Try this.
and ENSURE YOUR POSITIONS ARE CORRECT.
The entire script will break if you do the positions incorrectly.
F96VXaE.png

LUA:
local items = {
    mud_border = 4799,
    water = 493,
    bridge = 1284
}
local bridge_positions = {
    {x = 1111, y = 1111, z = 7},
    {x = 2222, y = 1111, z = 7},
    {x = 3333, y = 2222, z = 7},
    {x = 4444, y = 2222, z = 7}
}
local relocate_position = {x = 5555, y = 3333, z = 7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getTileItemById(bridge_positions[1], items.water).uid ~= 0 and item.itemid == 1945 then
        for i = 1, 4 do
            if not (i % 2 == 0) then
                doTransformItem(getTileItemById(bridge_positions[i], items.mud_border).uid, 0)
            end
            doTransformItem(getTileItemById(bridge_positions[i], items.water).uid, items.bridge)
        end
    elseif getTileItemById(bridge_positions[1], items.bridge).uid ~= 0 and item.itemid == 1946 then
        for i = 1, 4 do
            doRelocate(bridge_positions[i], relocate_position, true)
            if not (i % 2 == 0) then
                doCreateItem(items.mud_border, 1, bridge_positions[i])
            end
            doTransformItem(getTileItemById(bridge_positions[i], items.bridge).uid, items.water)
        end
    end
    doTransformItem(item.uid, item.itemid == 1946 and 1945 or 1946)
    return true
end
 
Solution
wtf. I literally explained how to script this step by step.
How you guys managed to turn 20 lines of code into 70 is a remarkable feat I don't even want to try to figure out.

Try this.
and ENSURE YOUR POSITIONS ARE CORRECT.
The entire script will break if you do the positions incorrectly.
F96VXaE.png

LUA:
local items = {
    mud_border = 4799,
    water = 493,
    bridge = 1284
}
local bridge_positions = {
    {x = 1111, y = 1111, z = 7},
    {x = 2222, y = 1111, z = 7},
    {x = 3333, y = 2222, z = 7},
    {x = 4444, y = 2222, z = 7}
}
local relocate_position = {x = 5555, y = 3333, z = 7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getTileItemById(bridge_positions[1], items.water).uid ~= 0 and item.itemid == 1945 then
        for i = 1, 4 do
            if not (i % 2 == 0) then
                doTransformItem(getTileItemById(bridge_positions[i], items.mud_border).uid, 0)
            end
            doTransformItem(getTileItemById(bridge_positions[i], items.water).uid, items.bridge)
        end
    elseif getTileItemById(bridge_positions[1], items.bridge).uid ~= 0 and item.itemid == 1946 then
        for i = 1, 4 do
            doRelocate(bridge_positions[i], relocate_position, true)
            if not (i % 2 == 0) then
                doCreateItem(items.mud_border, 1, bridge_positions[i])
            end
            doTransformItem(getTileItemById(bridge_positions[i], items.bridge).uid, items.water)
        end
    end
    doTransformItem(item.uid, item.itemid == 1946 and 1945 or 1946)
    return true
end
Worked perfectly !

thanks man and srry sometimes i don't understand a sh$t
it's not that I have not tried
 
Worked perfectly !

thanks man and srry sometimes i don't understand a sh$t
it's not that I have not tried
In all honesty, I wrote recklessly.
I hope that you and others strive to learn and continue growing.


I should stay away from here as I originally intended though.
Even though I sometimes want to continue with what's comfortable, I know I should be looking elsewhere.
Leaving OtLand.
 
Back
Top