• 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 [Action] Create item on location.

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 was working on a script that when activated changes certain items into other items and after a while changes them back. But when trying this with certain floor ids it removes the top items and doesn't put them back so I figured I just need to create it back ontop at the end of the change.

So if anyone knows the line of code to create an item with item id x and at location x y z. that would be awesome :)

Thanks in advance.
 
Code:
local function doTransformBack(Position, itemid, transformid)
    return doTransformItem(getTileItemById(Position, transformid).uid, itemid)
end

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

        if itemEx.itemid == 1945 and item.actionid == 65535 then
            doSendMagicEffect(toPosition,CONST_ME_ICEAREA)
            doTargetCombatHealth(0, cid, COMBAT_ICEDAMAGE, -1000, -1000, CONST_ME_ICEAREA)
            addEvent(doTransformBack, 2*6*1000, toPosition, itemEx.itemid, 7021)
            doTransformItem(itemEx.uid, 7021)

/~/
addEvent(doTransformBack, 2*6*1000, {x = 737, y = 997, z = 7}, getTileThingByPos({x = 737, y = 997, z = 7, stackpos = 0}).itemid, 485)
doSendMagicEffect({x = 737, y = 997, z = 7},CONST_ME_ICEAREA)
doTransformItem(getTileItemById({x = 737, y = 997, z = 7}, getTileThingByPos({x = 737, y = 997, z = 7, stackpos = 0}).itemid).uid, 485)

addEvent(doTransformBack, 2*6*1000, {x = 737, y = 997, z = 7}, 8632, 8060)
doTransformItem(getTileItemById({x = 737, y = 997, z = 7}, 8632).uid, 8060)
/~/

end
     return TRUE
end


Before
30m91ma.png


During
ndJls0E.jpg



After
AqvZMpq.jpg


Hope this explains it better :)
 
Well, I don't see how this script changed all of that area.. ;)
But generally use stack positions.

Stack 0 = base ground
Use this to convert water to ice, and grass to snow.

Code:
x = 1000, y = 1000, z = 7, stackpos = 0
Stack 1 = item on top of base ground
Use this for the drop holes, and whirlpool, and to get rid of borders.

Code:
x = 1000, y = 1000, z = 7, stackpos = 1
Use this to create objects.
Stack position is important, as any items on the ground will be pushed up to stack = 2
If you don't use stack position, then items will be underneath objects created, and then all your stack positions will end up screwy.. possibly causing problems later on.
However it is useful sometimes if you need to create a magic wall (for example) that needs to go on top of everything.

Code:
doCreateItem(itemid, type/count, pos)
doCreateItem(1111, 1, {x = 1000, y = 1000, z = 7, stackpos = 1})
 
And about changing everything into snow etc I cut those lines out of the script because the post would be to long that way and it would be hard to locate this problem.

Just one more thing left to fix this how do I create an item with a delay? :)

ex: doCreateItem(8632, 1, {x = 737, y = 997, z = 7, stackpos = 1})
With delay 2*6*1000
 
That was a pretty stupid question :D been using it in the same script all over again, guess I should keep my head at it while scripting ;)

Code:
local function doTransformBack(Position, itemid, transformid)
return doTransformItem(getTileItemById(Position, transformid).uid, itemid)
end

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

if itemEx.itemid == 1945 and item.actionid == 65535 then
doSendMagicEffect(toPosition,CONST_ME_ICEAREA)
doTargetCombatHealth(0, cid, COMBAT_ICEDAMAGE, -1000, -1000, CONST_ME_ICEAREA)
addEvent(doTransformBack, 2*6*1000, toPosition, itemEx.itemid, 7021)
doTransformItem(itemEx.uid, 7021)

/~/
addEvent(doTransformBack, 2*6*1000, {x = 737, y = 997, z = 7}, getTileThingByPos({x = 737, y = 997, z = 7, stackpos = 0}).itemid, 485)
doSendMagicEffect({x = 737, y = 997, z = 7},CONST_ME_ICEAREA)
doTransformItem(getTileItemById({x = 737, y = 997, z = 7}, getTileThingByPos({x = 737, y = 997, z = 7, stackpos = 0}).itemid).uid, 485)

doTransformItem(getTileItemById({x = 737, y = 997, z = 7}, 8632).uid, 8060)
addEvent(doCreateItem, 2*6*1000, 8632, 1, {x = 737, y = 997, z = 7, stackpos = 1})
end
return TRUE
end
 
Last edited:
Oke thx but this problem is allready solved as mentioned above ;) Anyway feel free to check out any other problems I'm currently having. Here
 
Back
Top