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

Action (Solved)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
This is the Dreamer's Challenge Quest script, part of Death ring, Life ring ..
OnUse.
I made this script myself.
Is possible to simplify? It's too much lines
LUA:
function onUse(cid, item, frompos, item2, topos)

gatepos = {x=32996, y=32272, z=10, stackpos=1}
getgate = getThingfromPos(gatepos)
gatepos2 = {x=32999, y=32269, z=10, stackpos=1}
getgate2 = getThingfromPos(gatepos2)
gatepos3 = {x=33002, y=32272, z=10, stackpos=1}
getgate3 = getThingfromPos(gatepos3)
gatepos4 = {x=32999, y=32275, z=10, stackpos=1}
getgate4 = getThingfromPos(gatepos4)
gatepos5 = {x=32999, y=32272, z=10, stackpos=1}
getgate5 = getThingfromPos(gatepos5)
gatepos6 = {x=32992, y=32265, z=10, stackpos=1}
getgate6 = getThingfromPos(gatepos6)
gatepos7 = {x=32993, y=32265, z=10, stackpos=1}
getgate7 = getThingfromPos(gatepos7)
gatepos8 = {x=32992, y=32266, z=10, stackpos=1}
getgate8 = getThingfromPos(gatepos8)
gatepos9 = {x=32993, y=32266, z=10, stackpos=1}
getgate9 = getThingfromPos(gatepos9)
gatepos10 = {x=32997, y=32270, z=10, stackpos=1}
getgate10 = getThingfromPos(gatepos10)
gatepos11 = {x=33001, y=32270, z=10, stackpos=1}
getgate11 = getThingfromPos(gatepos11)
gatepos12 = {x=32997, y=32274, z=10, stackpos=1}
getgate12 = getThingfromPos(gatepos12)
gatepos13 = {x=33001, y=32274, z=10, stackpos=1}
getgate13 = getThingfromPos(gatepos13)

if item.uid == 34582 and getgate2.itemid == 2168 and getgate3.itemid == 1492 and getgate4.itemid == 6300 and getgate6.itemid == 3729 and getgate7.itemid == 3730 and getgate8.itemid == 3731 and getgate9.itemid == 3732 then
doRemoveItem(getgate2.uid,1)
doRemoveItem(getgate3.uid,1)
doRemoveItem(getgate4.uid,1)
doRemoveItem(getgate6.uid,1)
doRemoveItem(getgate7.uid,1)
doRemoveItem(getgate8.uid,1)
doRemoveItem(getgate9.uid,1)
doCreateItem(3733,1,gatepos6)
doCreateItem(3734,1,gatepos7)
doCreateItem(3735,1,gatepos8)
doCreateItem(3736,1,gatepos9)
doCreateItem(5070,1,gatepos10)
doCreateItem(5070,1,gatepos11)
doCreateItem(5070,1,gatepos12)
doCreateItem(5070,1,gatepos13)
else
end
end
 
Last edited:
Try:
LUA:
local positions = {{x=32996, y=32272, z=10, stackpos=1}, {x=32999, y=32269, z=10, stackpos=1}, {x=33002, y=32272, z=10, stackpos=1}, {x=32999, y=32275, z=10, stackpos=1}}
local items = {xxxx,xxxx,xxxx,xxxx} 

function onUse(cid, item)
for i = 1, #positions do
    if getThingfromPos(positions[i]).itemid == items[i] then
       doCreateTeleport(1387, topos, createpos)
       doRemoveItem(getThingfromPos(positions[i]).uid, 1)
    else
        doPlayerSendCancel(cid, "All items must be in correct order?")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
end
return true
end
 
Look at this Santi, i saw that my script was incorrect,
OnUse.
I made this script myself.
Is possible to simplify? It's too much lines
LUA:
function onUse(cid, item, frompos, item2, topos)

gatepos = {x=32996, y=32272, z=10, stackpos=1}
getgate = getThingfromPos(gatepos)
gatepos2 = {x=32999, y=32269, z=10, stackpos=1}
getgate2 = getThingfromPos(gatepos2)
gatepos3 = {x=33002, y=32272, z=10, stackpos=1}
getgate3 = getThingfromPos(gatepos3)
gatepos4 = {x=32999, y=32275, z=10, stackpos=1}
getgate4 = getThingfromPos(gatepos4)
gatepos5 = {x=32999, y=32272, z=10, stackpos=1}
getgate5 = getThingfromPos(gatepos5)
gatepos6 = {x=32992, y=32265, z=10, stackpos=1}
getgate6 = getThingfromPos(gatepos6)
gatepos7 = {x=32993, y=32265, z=10, stackpos=1}
getgate7 = getThingfromPos(gatepos7)
gatepos8 = {x=32992, y=32266, z=10, stackpos=1}
getgate8 = getThingfromPos(gatepos8)
gatepos9 = {x=32993, y=32266, z=10, stackpos=1}
getgate9 = getThingfromPos(gatepos9)
gatepos10 = {x=32997, y=32270, z=10, stackpos=1}
getgate10 = getThingfromPos(gatepos10)
gatepos11 = {x=33001, y=32270, z=10, stackpos=1}
getgate11 = getThingfromPos(gatepos11)
gatepos12 = {x=32997, y=32274, z=10, stackpos=1}
getgate12 = getThingfromPos(gatepos12)
gatepos13 = {x=33001, y=32274, z=10, stackpos=1}
getgate13 = getThingfromPos(gatepos13)

if item.uid == 34582 and getgate2.itemid == 2168 and getgate3.itemid == 1492 and getgate4.itemid == 6300 and getgate6.itemid == 3729 and getgate7.itemid == 3730 and getgate8.itemid == 3731 and getgate9.itemid == 3732 then
doRemoveItem(getgate2.uid,1)
doRemoveItem(getgate3.uid,1)
doRemoveItem(getgate4.uid,1)
doRemoveItem(getgate6.uid,1)
doRemoveItem(getgate7.uid,1)
doRemoveItem(getgate8.uid,1)
doRemoveItem(getgate9.uid,1)
doCreateItem(3733,1,gatepos6)
doCreateItem(3734,1,gatepos7)
doCreateItem(3735,1,gatepos8)
doCreateItem(3736,1,gatepos9)
doCreateItem(5070,1,gatepos10)
doCreateItem(5070,1,gatepos11)
doCreateItem(5070,1,gatepos12)
doCreateItem(5070,1,gatepos13)
else
end
end
 
Hmm, try:
LUA:
local checkPositions = { 
{x=32999, y=32269, z=10, stackpos=1}, 
{x=33002, y=32272, z=10, stackpos=1}, 
{x=32999, y=32275, z=10, stackpos=1},
{x=32992, y=32265, z=10, stackpos=1},
{x=32993, y=32265, z=10, stackpos=1},
{x=32992, y=32266, z=10, stackpos=1},
{x=32993, y=32266, z=10, stackpos=1}
}

local checkItems = {2168,1492,6300,3729,3730,3731,3732}

local createPositions = {
{x=32992, y=32265, z=10, stackpos=1},
{x=32993, y=32265, z=10, stackpos=1},
{x=32992, y=32266, z=10, stackpos=1},
{x=32993, y=32266, z=10, stackpos=1},
{x=32997, y=32270, z=10, stackpos=1},
{x=33001, y=32270, z=10, stackpos=1},
{x=32997, y=32274, z=10, stackpos=1},
{x=33001, y=32274, z=10, stackpos=1}
}

local createItems = {3733,3734,3735,3736,5070,5070,5070,5070} 
-- Each item for each position [cada item tem q ir pra cada posicao up(createpositions)])
local a = 1
function onUse(cid, item)
for i = 1, #checkPositions do
    if getThingfromPos(checkPositions[i]).itemid == checkItems[i] then
       doRemoveItem(getThingfromPos(checkPositions[i]).uid, 1)
       a = a + 1
       if a == 8 then
          break
       end
          for j = 1, #createPositions do
              doCreateItem(createItems[i], 1, createPositions[i])
          end
    else
        doPlayerSendCancel(cid, "Some items are not in correct pos")
    end
end
return true
end
 
Last edited:
OMG, great bug.
The dried well can only be removed and energy can appear only if itens removed (death ring, fire field, life ring)

imagemqqm.jpg


LUA:
function onUse(cid, item, frompos, item2, topos)

gatepos2 = {x=32999, y=32269, z=10, stackpos=1}
getgate2 = getThingfromPos(gatepos2)
gatepos3 = {x=33002, y=32272, z=10, stackpos=1}
getgate3 = getThingfromPos(gatepos3)
gatepos4 = {x=32999, y=32275, z=10, stackpos=1}
getgate4 = getThingfromPos(gatepos4)
gatepos6 = {x=32992, y=32265, z=10, stackpos=1}
getgate6 = getThingfromPos(gatepos6)
gatepos7 = {x=32993, y=32265, z=10, stackpos=1}
getgate7 = getThingfromPos(gatepos7)
gatepos8 = {x=32992, y=32266, z=10, stackpos=1}
getgate8 = getThingfromPos(gatepos8)
gatepos9 = {x=32993, y=32266, z=10, stackpos=1}
getgate9 = getThingfromPos(gatepos9)
gatepos10 = {x=32997, y=32270, z=10, stackpos=1}
getgate10 = getThingfromPos(gatepos10)
gatepos11 = {x=33001, y=32270, z=10, stackpos=1}
getgate11 = getThingfromPos(gatepos11)
gatepos12 = {x=32997, y=32274, z=10, stackpos=1}
getgate12 = getThingfromPos(gatepos12)
gatepos13 = {x=33001, y=32274, z=10, stackpos=1}
getgate13 = getThingfromPos(gatepos13)

if item.uid == 34582 and item.itemid == 1945 and getgate2.itemid == 2168 and getgate3.itemid == 1492 and getgate4.itemid == 6300 and getgate6.itemid == 3729 and getgate7.itemid == 3730 and getgate8.itemid == 3731 and getgate9.itemid == 3732 then
doRemoveItem(getgate2.uid,1)
doRemoveItem(getgate3.uid,1)
doRemoveItem(getgate4.uid,1)
doRemoveItem(getgate6.uid,1)
doRemoveItem(getgate7.uid,1)
doRemoveItem(getgate8.uid,1)
doRemoveItem(getgate9.uid,1)
doCreateItem(3733,1,gatepos6)
doCreateItem(3734,1,gatepos7)
doCreateItem(3735,1,gatepos8)
doCreateItem(3736,1,gatepos9)
doCreateItem(5070,1,gatepos10)
doCreateItem(5070,1,gatepos11)
doCreateItem(5070,1,gatepos12)
doCreateItem(5070,1,gatepos13)
doTransformItem(item.uid, 1946)

elseif item.uid == 34582 and item.itemid == 1946 then
doTransformItem(item.uid, 1945)
end
end
is possible to simplify it without bug?
 
The doPlayerSendCancel bug was cause I forgot about the 'cid'
But What's the bug apart from that one?
 
My map part is not rl coords, this sparks are not being created in server start, it is created when player push the lever, like real tibia.
 
That's right, but in real tibia you can pull the lever always (but teleport will be created only if all 4 items are in place)
Also it can create the teleport even if you pull the lever first, and then put the 4 items on the tiles (which means you need onAddItem)
 
1° You push the lever and sparks appears.
2° When you stepin teleport erros appears when try to remove it.

I just want to remove it without any errors (remove the sparks, it's not spawn of map, it's created when you push the lever)
 
That's right, but in real tibia you can pull the lever always (but teleport will be created only if all 4 items are in place)
Also it can create the teleport even if you pull the lever first, and then put the 4 items on the tiles (which means you need onAddItem)

Easier onThink?
 
How is it a waste? IMO It's a bit easier makin it on think that onAddItem and onUse
How is it easier? And it's a waste of CPU cycles because you would check for the items constantly every 1 sec or something, instead of only when player triggers the action.
 
How is it easier? And it's a waste of CPU cycles because you would check for the items constantly every 1 sec or something, instead of only when player triggers the action.

Creaturescript wouldn't check each second? It checks when It's done? Or am I wrong? ;/
 
Back
Top