• 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 Remove 3 stones by 1 click.

PRLOts

Member
Joined
Jun 24, 2017
Messages
116
Solutions
4
Reaction score
15
I'm using [8.60] The Forgotten Server 0.3.6 (Crying Damson) V8 from here.

Hello guys, I have no idea why this script is not working.

Lua:
function onUse(cid, item, frompos, item2, topos)
    piece1pos = {x=1623, y=1408, z=6, stackpos=1}
    gate1pos = {x=1624, y=1404, z=6, stackpos=1}
    gate2pos = {x=1625, y=1404, z=6, stackpos=1}
    gate3pos = {x=1626, y=1404, z=6, stackpos=1}

    getpiece1 = getThingfromPos(piece1pos)
    getgate1 = getThingfromPos(gate1pos)
    getgate2 = getThingfromPos(gate2pos)
    getgate3 = getThingfromPos(gate3pos)

    if item.uid == 10339 and item.itemid == 1945 and getpiece1.itemid == 2366 and getgate1.itemid == 1304 and getgate2.itemid == 1304 and getgate3.itemid == 1304 then
        doRemoveItem(getpiece1.uid,1)
        doRemoveItem(getgate1.uid,1)
        doRemoveItem(getgate2.uid,1)
        doRemoveItem(getgate3.uid,1)
        doTransformItem(item.uid,item.itemid+1)
    elseif item.uid == 10339 and item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)
    else
        doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
    end
    return 1
end

There is no errors in engine, when I click on switch, there is no errors but stones are not
disappear :( Anyone knows how why?
 
Last edited by a moderator:
Solution
First image stackpos =
0 = tile (dirt floor)
1 = first thing (border-top) <-- WRONG
2 = second thing (border-bottom)
3 = stone/TP <-- correct

Second image stackpos =
0 = tile (dirt floor)
1 = stone/TP <-- correct

gate1pos = {x=1624, y=1404, z=6, stackpos=1}

Since the script fetches the "thing" from position x,y,z at stackpos 1, it loads the correct thing in your second photo, but in the first photo it probably just loaded the border-top or bottom. Which would fail when you validate the itemid in the conditional statement that verifies the objects before erasing them.
Since there is ground floor there + border tile there, could it be stackpos is 2 instead of 1?
Is the uniqueids and actionids set up properly? Are the stones correct itemid? Which itemids does the getThingFromPos return?
 
okk.png
Since there is ground floor there + border tile there, could it be stackpos is 2 instead of 1?
Is the uniqueids and actionids set up properly? Are the stones correct itemid? Which itemids does the getThingFromPos return?

Hey Znote, thanks for reply. I fixed it by myself, the code look like this;

Code:
  function onUse(cid, item, frompos, item2, topos)
piece1pos = {x=1622, y=1406, z=6, stackpos=1}
gate1pos = {x=1624, y=1404, z=6, stackpos=1}
gate2pos = {x=1625, y=1404, z=6, stackpos=1}
gate3pos = {x=1626, y=1404, z=6, stackpos=1}

getpiece1 = getThingfromPos(piece1pos)
getgate1 = getThingfromPos(gate1pos)
getgate2 = getThingfromPos(gate2pos)
getgate3 = getThingfromPos(gate3pos)

if item.uid == 10339 and item.itemid == 1945 and getpiece1.itemid == 2366 and getgate1.itemid == 1304 and getgate2.itemid == 1304 and getgate3.itemid == 1304 then

doRemoveItem(getpiece1.uid,1)
doRemoveItem(getgate1.uid,1)
doRemoveItem(getgate2.uid,1)
doRemoveItem(getgate3.uid,1)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 10339 and item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
return 1
end

And the problem was not with code but with map. When stones were situated like in the second post script was not working, but I have no idea why :D
 
First image stackpos =
0 = tile (dirt floor)
1 = first thing (border-top) <-- WRONG
2 = second thing (border-bottom)
3 = stone/TP <-- correct

Second image stackpos =
0 = tile (dirt floor)
1 = stone/TP <-- correct

gate1pos = {x=1624, y=1404, z=6, stackpos=1}

Since the script fetches the "thing" from position x,y,z at stackpos 1, it loads the correct thing in your second photo, but in the first photo it probably just loaded the border-top or bottom. Which would fail when you validate the itemid in the conditional statement that verifies the objects before erasing them.
 
Solution
First image stackpos =
0 = tile (dirt floor)
1 = first thing (border-top) <-- WRONG
2 = second thing (border-bottom)
3 = stone/TP <-- correct

Second image stackpos =
0 = tile (dirt floor)
1 = stone/TP <-- correct

gate1pos = {x=1624, y=1404, z=6, stackpos=1}

Since the script fetches the "thing" from position x,y,z at stackpos 1, it loads the correct thing in your second photo, but in the first photo it probably just loaded the border-top or bottom. Which would fail when you validate the itemid in the conditional statement that verifies the objects before erasing them.

Thanks for answer, Znote. There is so many traps, when I wann to code something on my own :D
 
Back
Top