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

Lever removing XX walls for XX seconds (Got a beginning)

survivor

New Member
Joined
Mar 20, 2008
Messages
89
Reaction score
4
Hello,

I was wondering if anyone could make me a script where I pull a lever and 2 walls disappear and reappear after a couple of seconds..

I'm using: cryingdamson 0.3.6 (8.60) V82

///SOLVED///

WORKING SCRIPT (By Limos & ArtOfWork):

Code:
local positions = {
{x = 92, y = 118, z=7},
{x = 92, y = 119, z=7}
}
local wallid = 1546
local wall = {} -- should be a table
local time_ = 30

local function doCreateWalls()
for x = 1, #positions do
doCreateItem(wallid, 1, positions[x])
wall[x] = nil -- delete the table
end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if #wall < #positions then -- is the wall table empty
for x = 1, #positions do
wall[x] = getTileItemById(positions[x], wallid).uid
doRemoveItem(wall[x], 1)
end
addEvent(doCreateWalls, time_ * 1000)
doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
return true
else
doPlayerSendCancel(cid, "The walls are already removed.")
return false
end
end

yours,
 
Last edited:
Code:
local positions = {
     {x = 92, y = 118, z=7},
     {x = 92, y = 119, z=7}
}
local wallid = 1546

local function doCreateWalls()
     for x = 1, #positions do
         doCreateItem(wallid, 1, positions[x])
     end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
     for x = 1, #positions do
         local wall = getTileItemById(positions[x], wallid).uid
         if wall > 0 then
             doRemoveItem(wall, 1)
         else
             doPlayerSendCancel(cid, "The walls are already removed.")
             doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
             return true
         end
     end
     addEvent(doCreateWalls, 30 * 1000)
     doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
     return true
end
 
Last edited:
@Limos Although I like your shorter version mine was meant to handle any kind of tile.

I didn't feel like rewriting the script for the person because of the nature of the conversation.
 
The good thing with using getTileItemById is that there can't be any problems with other items on that position, like borders, gravel or people placing items there.
Since stackpos 1 will just take the first item on the ground, with getTileItemById it will always get the right item since it checks for itemid.
 
Omg Limos thank you! Was begging so long for this! You helped me out big time, merry X-mas :D

and artofwork, don't get your problem man, I told you it wasn't meant that way. Anyway, merry X-mas to you too :D

yours,
 
take it easy man.. as I told you I appreciate the help you gave me, sad it had to end this way.

Ontopic:

I cheered too soon.. The fences did dissappear and reappear, but when I try it again it doesn't work.
For some reason the movement script i got from artofwork does work correctly..
Think I'll just change the levers with StepOn tiles for now, these levers seem cursed for some reason :/

thanks for your help,
 
I did that you get a message "The walls are already removed." when you try it again in those 30 seconds.
I can help if you explain how you want it to work exactly, "doesn't work" isn't a clear description of what should be different.
 
I do get the message "The walls are already removed". I do not get an error message in the server at all.

First time I use it it works perfectly. After that the lever stays in used postition (1946), don't know if that supposed to be.

When I use the lever a couple of times, sometimes it opens and gives the "The walls are already removed" message again, but it only stays open for a couple of seconds. I can't find a pattern in it it seems randomly.

I gave the lever ActionID 810, also tried to give it UniqueID 1945.
 
Code:
local positions = {
   {x = 92, y = 118, z=7},
   {x = 92, y = 119, z=7}
}
local wallid = 1546
local wall = {} -- should be a table
local time_ = 30

local function doCreateWalls()
   for x = 1, #positions do
     doCreateItem(wallid, 1, positions[x])
     wall[x] = nil -- delete the table
   end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if #wall < #positions then -- is the wall table empty
        for x = 1, #positions do
            wall[x] = getTileItemById(positions[x], wallid).uid
            doRemoveItem(wall[x], 1)
        end
        addEvent(doCreateWalls, time_ * 1000)
        doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
        return true
    else
        doPlayerSendCancel(cid, "The walls are already removed.")
        return false
    end
end
 
Last edited:
is that script with time counter?
Code:
local positions = {
     {x = 92, y = 118, z=7},
     {x = 92, y = 119, z=7}
}
local wallid = 1546

local function doCreateWalls()
     for x = 1, #positions do
         doCreateItem(wallid, 1, positions[x])
     end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
     for x = 1, #positions do
         local wall = getTileItemById(positions[x], wallid).uid
         if wall > 0 then
             doRemoveItem(wall, 1)
         else
             doPlayerSendCancel(cid, "The walls are already removed.")
             doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
             return true
         end
     end
     addEvent(doCreateWalls, 30 * 1000)
     doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
     return true
end
Code:
addEvent(doCreateWalls, 30 * 1000)
The addEvent in this script creates the walls again after 30 seconds if that is what you mean.
 
Code:
addEvent(doCreateWalls, 30 * 1000)
The addEvent in this script creates the walls again after 30 seconds if that is what you mean.
what i mean is i need a script that remove t.e.x a wall automatic and its typing 10,9,8,7,6,5,4,3,2,1 and then the wall shows up again and then 20 sec - the wall will show up and again and again, sorry for my bad eng
 
Back
Top