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

-

  • Thread starter Thread starter Emky
  • Start date Start date
<action actionid="6003" event="script" value="stairhole.lua"/>

Copy above thing and add it instead of yours.

nah, that don't work, also my other lever scripts works correctly with the way that i typed it, i just think the logic in the script is incorrect, edited the title since it was kinda missleading i think
 
nah, that don't work, also my other lever scripts works correctly with the way that i typed it, i just think the logic in the script is incorrect, edited the title since it was kinda missleading i think
Hm, oh okay. I suck at scripting I can't really help you. :(

GL.
 
Ground tile stackpos is 0.

Maybe this work.
Code:
function onUse(cid, item, frompos, item2, topos)
     
-- dirt = 351
-- stair hole = 369

stairholePos = {x = 200, y = 300, z = 400, stackpos = 0}
getItem = getThingfromPos(stairholePos)

        if item.itemid == 1945 and getItem2.itemid == 351 then
                doTransformItem(getItem.uid,369)
                doTransformItem(item.uid,item.itemid+1)
        elseif item.itemid == 1946 and getItem.itemid == 369 then
                doTransformItem(getItem.uid,351)
                doTransformItem(item.uid,item.itemid-1)
        else
                doPlayerSendCancel(cid,"Sorry, not possible.")
        end
     
        return TRUE
end
 
Ground tile stackpos is 0.

Maybe this work.
Code:
function onUse(cid, item, frompos, item2, topos)
    
-- dirt = 351
-- stair hole = 369

stairholePos = {x = 200, y = 300, z = 400, stackpos = 0}
getItem = getThingfromPos(stairholePos)

        if item.itemid == 1945 and getItem2.itemid == 351 then
                doTransformItem(getItem.uid,369)
                doTransformItem(item.uid,item.itemid+1)
        elseif item.itemid == 1946 and getItem.itemid == 369 then
                doTransformItem(getItem.uid,351)
                doTransformItem(item.uid,item.itemid-1)
        else
                doPlayerSendCancel(cid,"Sorry, not possible.")
        end
    
        return TRUE
end

still gets "sorry, not possible"
 
Try this
Code:
local stairholePos = {x = 200, y = 300, z = 400, stackpos = 0}
local getTileItem = getThingfromPos(stairholePos)
local dirt = 351
local stairHole = 369
local switch = {off = 1945, on = 1946}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == switch.off and ( getTileItem.itemid ~= nil or getTileItem.itemid ~= 0 ) then
        doTransformItem(item.uid, switch.on)
        doTransformItem(getTileItem.uid, stairHole)
    elseif item.itemid == switch.on and getTileItem.itemid == stairHole then
        doTransformItem(item.uid, switch.off)
        doTransformItem(getTileItem.uid, dirt)
    else
        doPlayerSendCancel(cid, "Sorry, not possible.")
    end
    return true
end
 
Try this
Code:
local stairholePos = {x = 200, y = 300, z = 400, stackpos = 0}
local getTileItem = getThingfromPos(stairholePos)
local dirt = 351
local stairHole = 369
local switch = {off = 1945, on = 1946}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == switch.off and ( getTileItem.itemid ~= nil or getTileItem.itemid ~= 0 ) then
        doTransformItem(item.uid, switch.on)
        doTransformItem(getTileItem.uid, stairHole)
    elseif item.itemid == switch.on and getTileItem.itemid == stairHole then
        doTransformItem(item.uid, switch.off)
        doTransformItem(getTileItem.uid, dirt)
    else
        doPlayerSendCancel(cid, "Sorry, not possible.")
    end
    return true
end
thanks works very good :)
 
Try this
Code:
local stairholePos = {x = 200, y = 300, z = 400, stackpos = 0}
local getTileItem = getThingfromPos(stairholePos)
local dirt = 351
local stairHole = 369
local switch = {off = 1945, on = 1946}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == switch.off and ( getTileItem.itemid ~= nil or getTileItem.itemid ~= 0 ) then
        doTransformItem(item.uid, switch.on)
        doTransformItem(getTileItem.uid, stairHole)
    elseif item.itemid == switch.on and getTileItem.itemid == stairHole then
        doTransformItem(item.uid, switch.off)
        doTransformItem(getTileItem.uid, dirt)
    else
        doPlayerSendCancel(cid, "Sorry, not possible.")
    end
    return true
end
What did I miss? ;-0
 
What did I miss? ;-0
Your error is bold
if item.itemid == 1945 and getItem2.itemid == 351 then
The if statement never executes so the switch never changes which causes the elseif statement to never execute, so all that is left is the else statement.

But i wrote my script without looking at yours.
 
Try this
Code:
local stairholePos = {x = 200, y = 300, z = 400, stackpos = 0}
local getTileItem = getThingfromPos(stairholePos)
local dirt = 351
local stairHole = 369
local switch = {off = 1945, on = 1946}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == switch.off and ( getTileItem.itemid ~= nil or getTileItem.itemid ~= 0 ) then
        doTransformItem(item.uid, switch.on)
        doTransformItem(getTileItem.uid, stairHole)
    elseif item.itemid == switch.on and getTileItem.itemid == stairHole then
        doTransformItem(item.uid, switch.off)
        doTransformItem(getTileItem.uid, dirt)
    else
        doPlayerSendCancel(cid, "Sorry, not possible.")
    end
    return true
end

Could you reverse this script for me? (say i have a stone(1285) and a lever(1945) on the map and i want to remove the stone(not the dirt under it) when i turn off the lever. then when i turn the lever on again it will spawn the stone again aswell dirt under the stone)
 
Could you reverse this script for me? (say i have a stone(1285) and a lever(1945) on the map and i want to remove the stone(not the dirt under it) when i turn off the lever. then when i turn the lever on again it will spawn the stone again aswell dirt under the stone)
Ironically, OP's original script is what you'd want to use for that.
However, instead of removing the object, you'd want to transform it to 0.
(removing objects works for objects placed by players. Transform works for everything.. but requires you to know the exact position of the item on the map.)
(another safeguard required would be to relocate/remove all items underneath the stone.. before replacing it. I choose relocate.. because I don't believe in destroying players items.. unless they are meant to be destroyed.)
 
Back
Top