• 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 My first script: Remove and auto Create Wall in seconds with Lever

megachock

Member
Joined
Mar 12, 2009
Messages
115
Reaction score
7
Hey, this is my first script, i just followed some guides and i wanted to make this and finally i made it work.

What it does? When you pull the lever this will remove a wall from a position then in X seconds wall will appear again and the lever will be pulled back, also you can pull back the lever and create the wall.

Here it is:
In actions/actions.xml

Code:
<action actionid="23891" event="script" value="WallRemover.lua"/>

23891 is the actionid of the lever in the map.

In actions/scripts/
Copy any script and rename it WallRemover.lua
and paste it inside:

Code:
local pos = {x = 1656,  y = 1135,  z = 7}
local wall = 1544
local level = 70
local seconds = 3
local event = 0

local function reset(leverPos)
        local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    doCreateItem(wall, 1, pos)
        doPlayerSendTextMessage(cid,21,"The pass has been closed!")
end

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


          if item.itemid == 1945 and getPlayerLevel(cid) >= level then
                doRemoveItem(getTileItemById(pos,wall).uid)
                doPlayerSendTextMessage(cid,21,"You have opened the pass, Beware!")
                event = addEvent(reset, seconds * 1000, getThingPos(item.uid))
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 and getPlayerLevel(cid) >= level then
        stopEvent(event)
        doPlayerSendTextMessage(cid,21,"You have closed the pass!")
        doTransformItem(item.uid,item.itemid-1)
        doCreateItem(wall, 1, pos)
end
return true
end

wall = Wall ID
level = levelrequirement
pos = {position of the wall}
seconds = seconds the wall will appear again
 
Last edited:
Well i made it for a quest on my server jeje, im glad to see people is using it since its my first script,
Thanks
 
Are you sure that it shouldn't be uniqueid?

"local lever = getTileItemById(leverPos, 1946).uid"

And i got error with unique id, and didnt work [error - LuaInterface:loadFile] data/actions/scripts/wallremover.lua:1: '}' expected near 'y']

with action id, didnt work and no errors
 
Are you sure that it shouldn't be uniqueid?

"local lever = getTileItemById(leverPos, 1946).uid"

And i got error with unique id, and didnt work [error - LuaInterface:loadFile] data/actions/scripts/wallremover.lua:1: '}' expected near 'y']

with action id, didnt work and no errors

Lua:
local pos = {x = 1656,  y = 1135,  z = 7}
local wall = 1544
local level = 70
local seconds = 3
local event = 0
 
local function reset(leverPos)
        local lever = getTileItemById(leverPos, 1946).uid
	doTransformItem(lever, 1945)
	doCreateItem(wall, 1, pos)
        doPlayerSendTextMessage(cid,21,"The pass has been closed!")
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
 
          if item.itemid == 1945 and getPlayerLevel(cid) >= level then
                doRemoveItem(getTileItemById(pos,wall).uid)
                doPlayerSendTextMessage(cid,21,"You have opened the pass, Beware!")
                event = addEvent(reset, seconds * 1000, getThingPos(item.uid))
		doTransformItem(item.uid,item.itemid+1)
	elseif item.itemid == 1946 and getPlayerLevel(cid) >= level then
		stopEvent(event)
		doPlayerSendTextMessage(cid,21,"You have closed the pass!")
		doTransformItem(item.uid,item.itemid-1)
		doCreateItem(wall, 1, pos)
end
return true
end

I think you removed a } from the first local, please check it and use this script, you can use an uniqueid if you have more walls with that in that position because this remove only the item id.
Also remember to put the same aid to your lever.
 
Last edited:
Hello, Im looking for a script similar to this. I want a lever that appears 5 rocks next to each other is it possible to make a script like that?
 
Back
Top