• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

doRemoveItem

SasirO

Banned User
Joined
Apr 30, 2009
Messages
559
Reaction score
0
Hello, i need a script thats gonna remove 4 magic walls and the lever after pulling it.

Heres my actually script thats removing the magic walls, but i dont know how to add it so it removes the lever xd
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    removals = {
        { item = 1498, pos = { x = 32915 , y = 32076 , z = 6 } },
        { item = 1498, pos = { x = 32915 , y = 32081 , z = 6 } }
		{ item = 1498, pos = { x = 32915 , y = 32083 , z = 6 } }
		{ item = 1498, pos = { x = 32915 , y = 32084 , z = 6 } }
    }
    
     if item.itemid == 1945 then
        for i = 1, #removals do
            removals[i].pos.stackpos = 1
            doRemoveItem(getThingfromPos(removals[i].pos).uid, 1)
        end
    return TRUE
end
 
Cant u just add the lever in?

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    removals = {
        { item = 1498, pos = { x = 32915 , y = 32076 , z = 6 } },
        { item = 1498, pos = { x = 32915 , y = 32081 , z = 6 } },
        { item = 1945, pos = { x = XXX , y = YYY , z = ZZZ } },
        { item = 1946, pos = { x = XXX , y = YYY , z = ZZZ } }
		{ item = 1498, pos = { x = 32915 , y = 32083 , z = 6 } }
		{ item = 1498, pos = { x = 32915 , y = 32084 , z = 6 } }
    }
    
     if item.itemid == 1945 then
        for i = 1, #removals do
            removals[i].pos.stackpos = 1
            doRemoveItem(getThingfromPos(removals[i].pos).uid, 1)
        end
    return TRUE
end

Edit: Nvm.. that wont work XD
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    removals = { --Magic Walls
        { x = 32915 , y = 32076 , z = 6, stackpos = 1},
        { x = 32915 , y = 32081 , z = 6, stackpos = 1 },
		{ x = 32915 , y = 32083 , z = 6, stackpos = 1 },
		{ x = 32915 , y = 32084 , z = 6, stackpos = 1 }
    }
    
     if item.itemid == 1945 then
        for i = 1, #removals do
            doRemoveItem(getThingfromPos(removals[i].uid), 1)
        end
		doRemoveItem(item.uid, 1)
    return TRUE
end
 
Well i just copied from the first one and edited thats why i missed a end, theres no need of "id" to the lever since item.uid is the item being used....

AND IT WORKS!

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    removals = { --Magic Walls
        { x = 32915 , y = 32076 , z = 6, stackpos = 1},
        { x = 32915 , y = 32081 , z = 6, stackpos = 1 },
		{ x = 32915 , y = 32083 , z = 6, stackpos = 1 },
		{ x = 32915 , y = 32084 , z = 6, stackpos = 1 }
    }
    
     if item.itemid == 1945 then
        for i = 1, #removals do
            doRemoveItem(getThingfromPos(removals[i].uid), 1)
        end
		doRemoveItem(item.uid, 1)
	end	
    return TRUE
end
 
Anyways, i prefer my fixed version :s
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    removals = {
        { item = 386, pos = { x = 32186 , y = 31626 , z = 8 } },
        { item = 386, pos = { x = 32187 , y = 31626 , z = 8 } },
		{ item = 386, pos = { x = 32188 , y = 31626 , z = 8 } },
		{ item = 386, pos = { x = 32189 , y = 31626 , z = 8 } },   
		{ item = 1945, pos = { x = 32180 , y = 31633 , z = 8 } },   		
    }
    
    if item.itemid == 1945 then
        for i = 1, #removals do
            removals[i].pos.stackpos = 1
            doRemoveItem(getThingfromPos(removals[i].pos).uid, 1)
    end
    return TRUE
end 
end


But you can still help me by telling how to add magiceffect Puff into the lever and how to use event timer, so the magic walls and the lever rebuild after 1 minute
 
Ok here you go, but you will need to use mine, it works ive test it in my server so here it is:

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    removals = { --Magic Walls
        { x = 32915 , y = 32076 , z = 6, stackpos = 1},
        { x = 32915 , y = 32081 , z = 6, stackpos = 1 },
		{ x = 32915 , y = 32083 , z = 6, stackpos = 1 },
		{ x = 32915 , y = 32084 , z = 6, stackpos = 1 }
    }
    
     if item.itemid == 1945 then
        for i = 1, #removals do
            doRemoveItem(getThingfromPos(removals[i]).uid, 1)
        end
		local LeverPos = {x=123, y=123, z=7}
		doSendMagicEffect(LeverPos, 10)
		doRemoveItem(item.uid, 1)
		addEvent(reCreate, 60*1000)
	end	
    return TRUE
end

function reCreate()
	for i = 1, #removals do
		doCreateItem(1498, 1, removals[i])
	end
	local LeverPos = {x=123, y=123, z= 7}
	doCreateItem(1496, 1, LeverPos)
  return TRUE
end
 
Works perfectly, but theres just one small problem :d
its creating the switch without uniqueid ;/
So the next player cant pull the lever

Is there something like doSetItem Uniqueid?
 
Theres no function for unique just for action, you can use action istead of unique :D

Example:

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    removals = { --Magic Walls
        { x = 32915 , y = 32076 , z = 6, stackpos = 1},
        { x = 32915 , y = 32081 , z = 6, stackpos = 1 },
		{ x = 32915 , y = 32083 , z = 6, stackpos = 1 },
		{ x = 32915 , y = 32084 , z = 6, stackpos = 1 }
    }
    
     if item.itemid == 1945 then
        for i = 1, #removals do
            doRemoveItem(getThingfromPos(removals[i]).uid, 1)
        end
		local LeverPos = {x=123, y=123, z=7}
		doSendMagicEffect(LeverPos, 10)
		doRemoveItem(item.uid, 1)
		addEvent(reCreate, 60*1000)
	end	
    return TRUE
end

function reCreate()
	for i = 1, #removals do
		doCreateItem(1498, 1, removals[i])
	end
	local LeverPos = {x=123, y=123, z= 7}
	local cr = doCreateItem(1496, 1, LeverPos)
	doSetItemActionId(cr.uid, 890890)
  return TRUE
end
 
its not setting the lever action id number ;/

and another small problem Xd, if any player stays on the magic wall position then it creates only 3 magic walls instead of 4, is it possible to make it so the player gets moved ?

Edit: first problem solved, it should be like this:
Code:
 doSetItemActionId(cr, 56222)

And what about the second one?
 
Last edited:
Back
Top