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

Solved doTransformItem on different item

Exoltes

Novia OTserv Developer
Joined
Jul 2, 2009
Messages
563
Reaction score
47
Location
Belgium
I'm working on a 8.54 Open Tibia Server using The Forgotten Server - Version 0.2.7 (Mystic Spirit).

I'm trying to make a script with which you can open wooden coffins with a crowbar.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local function doTransformBack(pos, itemid, transformid)
     return doTransformItem(getTileItemById(pos, transformid).uid, itemid)
end
    if itemEx.itemid == 1742 then
        doTransformItem(itemEx.uid, 7520)
end
end

Instead of only changing the item on which i use the crowbar on i also want it to change the item to the south of it.

Thanks in advance.
 
Set 'newItemId' as the ID of the item you want it to be changed to; set the value of 'itemSouthPos' as the position of the item you want to change.

Code:
newItemId = 1945
itemSouthPos = {x = 32804, y = 31584, z = 1, stackpos = 1}
itemSouth = getThingfromPos(itemSouthPos)
doTransformItem(itemSouth.uid, newItemId)

There are probably better ways, but this still works.

Editted: and, ofcourse, check if the stackpos of the item you want to change is really 1.
 
Well the thing is, I can't make it locked on a certain sqm since the item I want it to work on is on many places in my map. But thx anyway :)
 
if it is a wooden coffin, set the position of the item you want to change as the same of the wooden coffin, but just add "+1" to 'y'.
open RME, use the "Find item" tool to find all the wooden coffins all over the map, add the action ID to all of them.

Editted: like this
Code:
itemSouthPos = toPosition
itemSouthPos.y = toPosition.y + 1

Editted #2: don't forget to add a conditional in the beginning of the script to only execute the commands if the itemid is the wooden coffin (so it won't execute if the item is an open wooden coffin)

Editted #3: ofcourse that, if it is a horizontal wooden coffin, you need to add 1 to the x coordinate, and not the y. So, to the test I just suggested:
Code:
if item.itemid == 1742 then
(...)
itemSouthPos.y = toPosition.y + 1
(...)
elseif item.itemid == 1744 then
(...)
itemEastPos.x = toPosition.x + 1
(...)
else
doPlayerSendCancel(cid, "Sorry, not possible.")
end
 
Last edited:
Fixed.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local function doTransformBack(pos, itemid, transformid)
return doTransformItem(getTileItemById(pos, transformid).uid, itemid)
end
if itemEx.itemid == 1744 then
        doTransformItem(itemEx.uid, 7522)
        doTransformItem(getTileItemById({x = toPosition.x + 1, y = toPosition.y, z = toPosition.z}, 1745).uid, 7523)
end
end

Credits go to Limos.
 
Back
Top