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

Kazordoon Elevator

Udun

Well-Known Member
Joined
Jan 5, 2012
Messages
192
Solutions
1
Reaction score
67
Hello there, today I want to share this little script that someone might need.
The script is of Cykotitan (credits to him), I saw it as response on a thread where someone need it but I want to explain it in more detail here.

Tested on TFS 0.3.6, idk if works in others.

So we go to:
data/actions/scripts, there we'll create a .lua file called kaz_elev
Inside will put this:


Lua:
local t = {
    {x=2657, y=1655, z=7}, --coordinate of the tile down the elevator
    {x=2657, y=1655, z=2}  --coordinate of the tile up the elevator
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local r = item.itemid == 1945
    doRelocate(t[r and 1 or 2], t[r and 2 or 1])
    doSendMagicEffect(t[1], CONST_ME_POFF)
    doSendMagicEffect(t[2], CONST_ME_POFF)
    return doTransformItem(item.uid, r and 1946 or 1945)
end

NOTE: Remember to check on your map editor the sqms where the player must be to use the elevator to configure the script.

Then we go to our actions.xml
We choose an action id with no use and put this (Note: in the XXXX you must put the action id):


XML:
    <!-- Kaz elevator--> 
    <action actionid="XXXX" event="script" value="kaz_elev.lua"/>

Now we need to go to our map on the map editor and put the action ids on each lever of the kaz elevator and that should do the magic.

I hope this will be useful.
Have a nice day.
 
Hi, it bugs in the client side tho, it works perfectly with monsters and items, but when you're in the client side, you are relocated to the right sqm, but your view is like you went to the 2nd floor or -2 floor, any fixes for it?
 
Hi, it bugs in the client side tho, it works perfectly with monsters and items, but when you're in the client side, you are relocated to the right sqm, but your view is like you went to the 2nd floor or -2 floor, any fixes for it?
I have no idea why that error is happening
I tested on 0.3.6 and 1.2 and works fine for me, i'm using otclient
I don't know what version are you using or client, maybe there is the problem
 
Yo, i have fixed lot of bugs in 7.72 server i'm working on. With last version of otclient in 1.0 Othire version i still have this client view crash. look at it:

otclient-df422c0_Pt6CXhrbJr.png
Now if i relog i get rid of this:
otclient-df422c0_OZpqIlQGsu.png
If i use the lever back, i have no problems in the other floor, but if i use it again, i get the same bug again. It is not the floor but where i first use the lever, the next lever i get relocated to turn bugged. If i walk with this bugged view, i get this:
otclient-df422c0_56b5EPQ3gi.png

Any clue what can be happening? Idk if it is client sided issue because i got this problem with the normal tibia 7.72 client also.
 
Yo, i have fixed lot of bugs in 7.72 server i'm working on. With last version of otclient in 1.0 Othire version i still have this client view crash. look at it:

View attachment 53094
Now if i relog i get rid of this:
View attachment 53095
If i use the lever back, i have no problems in the other floor, but if i use it again, i get the same bug again. It is not the floor but where i first use the lever, the next lever i get relocated to turn bugged. If i walk with this bugged view, i get this:
View attachment 53096

Any clue what can be happening? Idk if it is client sided issue because i got this problem with the normal tibia 7.72 client also.

Might be an issue with doRelocate.
I assume there is some weird packet issue that was solved in later tfs versions that wasn't fixed in othire

Try finding all creatures on the tile and doTeleport, and then use doRelocate to move all the items.
 
Might be an issue with doRelocate.
I assume there is some weird packet issue that was solved in later tfs versions that wasn't fixed in othire

Try finding all creatures on the tile and doTeleport, and then use doRelocate to move all the items.
Thank you very much! Would you help me fixing the script if you have any time? I dont know how to find all the creatures on the tile to be honest lol
 
I don't think getSpectators exists in your version..

Try something like this?

Lua:
local config = {
    {
        {x = 2657, y = 1655, z = 7}, -- lever down position
        {x = 2657, y = 1655, z = 7}  -- tile down position
    },
    {
        {x = 2657, y = 1655, z = 7}, -- lever up position
        {x = 2657, y = 1655, z = 7}  -- tile up position
    },
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local from, to = 2, 1
    if toPosition.x == config[1][1].x and toPosition.y == config[1][1].y and toPosition.z == config[1][1].z then
        from = 1
        to = 2
    end
    for i = 1, 255 do
        if isPlayer(getTopCreature(config[from][2]).uid) then
            doTeleportThing(getTopCreature(config[from][2]).uid, config[to][2])
        else
            break
        end
    end
    doRelocate(config[from][2], config[to][2])
    doSendMagicEffect(config[1][2], CONST_ME_POFF)
    doSendMagicEffect(config[2][2], CONST_ME_POFF)
    return doTransformItem(item.uid, r and 1946 or 1945)
end
 
I don't think getSpectators exists in your version..

Try something like this?

Lua:
local config = {
    {
        {x = 2657, y = 1655, z = 7}, -- lever down position
        {x = 2657, y = 1655, z = 7}  -- tile down position
    },
    {
        {x = 2657, y = 1655, z = 7}, -- lever up position
        {x = 2657, y = 1655, z = 7}  -- tile up position
    },
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local from, to = 2, 1
    if toPosition.x == config[1][1].x and toPosition.y == config[1][1].y and toPosition.z == config[1][1].z then
        from = 1
        to = 2
    end
    for i = 1, 255 do
        if isPlayer(getTopCreature(config[from][2]).uid) then
            doTeleportThing(getTopCreature(config[from][2]).uid, config[to][2])
        else
            break
        end
    end
    doRelocate(config[from][2], config[to][2])
    doSendMagicEffect(config[1][2], CONST_ME_POFF)
    doSendMagicEffect(config[2][2], CONST_ME_POFF)
    return doTransformItem(item.uid, r and 1946 or 1945)
end
Thank you buddy, you really helped me a lot, i managed to have it fully working as expected (moving lever left to right, in any floor, teleport everything in the lower tile to the upper floor, if moving lever right to left then teleport everything from upper floor to lower floor, and both levers changing positions together at the same time. It's working 100% as expected thank to you, i leave the code for anyone who needs it working in 1.0 versions. Love you! <3


Lua:
local config = {
        {x = 32636, y = 31881, z = 7, stackpos=253},  -- tile down position
        {x = 32636, y = 31881, z = 2, stackpos=253}  -- tile up position
}

    local switches = {
        [1] = {x = 32637, y = 31881, z = 2},
        [2] = {x = 32637, y = 31881, z = 7}
        }

function onUse(cid, item, fromPosition, itemEx, toPosition)

if item.itemid == 1945 then
    for i = 1, 255 do
        if isPlayer(getTopCreature(config[1]).uid) then
            doTeleportThing(getTopCreature(config[1]).uid, config[2])
        end
    end
    doRelocate(config[1], config[2])
    doSendMagicEffect(config[1], CONST_ME_POFF)
    doSendMagicEffect(config[2], CONST_ME_POFF)
    doTransformItem(getTileItemById(switches[1],1945).uid,1946)
    doTransformItem(getTileItemById(switches[2],1945).uid,1946)
    elseif item.itemid == 1946 then
    for i = 1, 255 do
        if isPlayer(getTopCreature(config[2]).uid) then
            doTeleportThing(getTopCreature(config[2]).uid, config[1])
        end
    end
    doRelocate(config[2], config[1])
    doSendMagicEffect(config[1], CONST_ME_POFF)
    doSendMagicEffect(config[2], CONST_ME_POFF)
    doTransformItem(getTileItemById(switches[1],1946).uid,1945)
    doTransformItem(getTileItemById(switches[2],1946).uid,1945)
end
return true    
end
 
Last edited:
Thank you buddy, you really helped me a lot, i managed to have it fully working as expected (moving lever left to right, in any floor, teleport everything in the lower tile to the upper floor, if moving lever right to left then teleport everything from upper floor to lower floor, and both levers changing positions together at the same time. It's working 100% as expected thank to you, i leave the code for anyone who needs it working in 1.0 versions. Love you! <3


Lua:
local config = {
        {x = 32636, y = 31881, z = 7, stackpos=253},  -- tile down position
        {x = 32636, y = 31881, z = 2, stackpos=253}  -- tile up position
}

    local switches = {
        [1] = {x = 32637, y = 31881, z = 2},
        [2] = {x = 32637, y = 31881, z = 7}
        }

function onUse(cid, item, fromPosition, itemEx, toPosition)

if item.itemid == 1945 then
    for i = 1, 255 do
        if isPlayer(getTopCreature(config[1]).uid) then
            doTeleportThing(getTopCreature(config[1]).uid, config[2])
        end
    end
    doRelocate(config[1], config[2])
    doSendMagicEffect(config[1], CONST_ME_POFF)
    doSendMagicEffect(config[2], CONST_ME_POFF)
    doTransformItem(getTileItemById(switches[1],1945).uid,1946)
    doTransformItem(getTileItemById(switches[2],1945).uid,1946)
    elseif item.itemid == 1946 then
    for i = 1, 255 do
        if isPlayer(getTopCreature(config[2]).uid) then
            doTeleportThing(getTopCreature(config[2]).uid, config[1])
        end
    end
    doRelocate(config[2], config[1])
    doSendMagicEffect(config[1], CONST_ME_POFF)
    doSendMagicEffect(config[2], CONST_ME_POFF)
    doTransformItem(getTileItemById(switches[1],1946).uid,1945)
    doTransformItem(getTileItemById(switches[2],1946).uid,1945)
end
return true   
end
Won't pretend to understand what I did wrong.. but you need to have breaks in your loops.. otherwise it can be severely abused as a lag machine.

Lua:
local config = {
    {x = 32636, y = 31881, z = 7, stackpos=253},  -- tile down position
    {x = 32636, y = 31881, z = 2, stackpos=253}  -- tile up position
}

local switches = {
    [1] = {x = 32637, y = 31881, z = 2},
    [2] = {x = 32637, y = 31881, z = 7}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if item.itemid == 1945 then
        for i = 1, 255 do
            if isPlayer(getTopCreature(config[1]).uid) then
                doTeleportThing(getTopCreature(config[1]).uid, config[2])
            else
                break
            end
        end
        doRelocate(config[1], config[2])
        doSendMagicEffect(config[1], CONST_ME_POFF)
        doSendMagicEffect(config[2], CONST_ME_POFF)
        doTransformItem(getTileItemById(switches[1],1945).uid,1946)
        doTransformItem(getTileItemById(switches[2],1945).uid,1946)
    elseif item.itemid == 1946 then
        for i = 1, 255 do
            if isPlayer(getTopCreature(config[2]).uid) then
                doTeleportThing(getTopCreature(config[2]).uid, config[1])
            else
                break
            end
        end
        doRelocate(config[2], config[1])
        doSendMagicEffect(config[1], CONST_ME_POFF)
        doSendMagicEffect(config[2], CONST_ME_POFF)
        doTransformItem(getTileItemById(switches[1],1946).uid,1945)
        doTransformItem(getTileItemById(switches[2],1946).uid,1945)
    end
    return true    
end
 
Won't pretend to understand what I did wrong.. but you need to have breaks in your loops.. otherwise it can be severely abused as a lag machine.

Lua:
local config = {
    {x = 32636, y = 31881, z = 7, stackpos=253},  -- tile down position
    {x = 32636, y = 31881, z = 2, stackpos=253}  -- tile up position
}

local switches = {
    [1] = {x = 32637, y = 31881, z = 2},
    [2] = {x = 32637, y = 31881, z = 7}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if item.itemid == 1945 then
        for i = 1, 255 do
            if isPlayer(getTopCreature(config[1]).uid) then
                doTeleportThing(getTopCreature(config[1]).uid, config[2])
            else
                break
            end
        end
        doRelocate(config[1], config[2])
        doSendMagicEffect(config[1], CONST_ME_POFF)
        doSendMagicEffect(config[2], CONST_ME_POFF)
        doTransformItem(getTileItemById(switches[1],1945).uid,1946)
        doTransformItem(getTileItemById(switches[2],1945).uid,1946)
    elseif item.itemid == 1946 then
        for i = 1, 255 do
            if isPlayer(getTopCreature(config[2]).uid) then
                doTeleportThing(getTopCreature(config[2]).uid, config[1])
            else
                break
            end
        end
        doRelocate(config[2], config[1])
        doSendMagicEffect(config[1], CONST_ME_POFF)
        doSendMagicEffect(config[2], CONST_ME_POFF)
        doTransformItem(getTileItemById(switches[1],1946).uid,1945)
        doTransformItem(getTileItemById(switches[2],1946).uid,1945)
    end
    return true
end
In fact i was wrong, both levers doesn't change of direction together. What was wrong with your code is the fact it's supposed to go up when you use the lever in id 1945 and go down when using it in id 1946, in your code if it's 1945 or 1946 you go down or up anyway, depending on wich floor you are standing at the momment of using it :p

This is the final code as it works in tibia RL:


Lua:
local config = {
        {x = 32636, y = 31881, z = 7, stackpos=253},  -- tile down position
        {x = 32636, y = 31881, z = 2, stackpos=253}  -- tile up position
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local r = item.itemid == 1945
if item.itemid == 1945 then
    for i = 1, 255 do
        if isPlayer(getTopCreature(config[1]).uid) then
            doTeleportThing(getTopCreature(config[1]).uid, config[2])
        end
    end
    doRelocate(config[1], config[2])
    doSendMagicEffect(config[1], CONST_ME_POFF)
    doSendMagicEffect(config[2], CONST_ME_POFF)
    return doTransformItem(item.uid, r and 1946 or 1945)
    elseif item.itemid == 1946 then
    for i = 1, 255 do
        if isPlayer(getTopCreature(config[2]).uid) then
            doTeleportThing(getTopCreature(config[2]).uid, config[1])
        end
    end
    doRelocate(config[2], config[1])
    doSendMagicEffect(config[1], CONST_ME_POFF)
    doSendMagicEffect(config[2], CONST_ME_POFF)
    return doTransformItem(item.uid, r and 1946 or 1945)
end
return true  
end
 
Last edited:
Back
Top