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

Remove all items from a SQM?

d4rkbl0od

Member
Joined
Mar 21, 2008
Messages
160
Reaction score
7
Is it possible to remove all items from a floor when pulling a lever?
Example, when i pull a lever all itens that are moveable, fields, etc are removed from that SQM, but not the ground floor!
 
When you use this it will remove all items from(moveble and magic fields) players position
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)	
for i = 255,1,-1 do
	local p = getThingPos(cid)
	local pos = {x=p.x,y=p.y,z=p.z,stackpos = i}
	local items = getThingFromPos(pos).uid
	
	if items > 0 then
		if not isCreature(items) and not isPlayer(items) then
			if isMovable(items) or getItemDescriptionsById(getThingFromPos(pos).itemid).type == ITEM_TYPE_MAGICFIELD then
				doRemoveItem(items)
			end
		end
	end
end
	return true
end
 
Last edited:
Code:
local starting = {x = 0, y = 0, z = 0} -- edit this to the top left
local ending = {x = 0, y = 0, z = 0} -- edit this to the bottom right

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local checking = {x = starting.x, y = starting.y, z = starting.z, stackpos = 253}
	local id = {}
	while checking.y <= ending.y do
		local thing = getThingFromPos(checking, false).uid
		if isCreature(thing) then
			return false
		end
		
		if checking.x == ending.x then
			checking.x = starting.x
			checking.y = checking.y + 1
		end
		
		checking.x = checking.x + 1
	end
	
	for _, items in ipairs(id) do
		doRemoveItem(items)
	end
	
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Last edited:
I made checks so there wont be errors, and i dont think he will put a pos that wont be there lol.
 
Last edited:
well, let me see, thanks for the help people! but i think JDB's code is more usefull for me , because there are 4 levers, and if 3 levers are pressioned, and a player enter the teleport, all 3 levers SHOULD return back to 1945, but players always try to finds ways to bug the server..... , and started throwing things over the levers, heheh,
so it will "clean" all this area, and then ,if i complete this code, it will create new levers 1945 with respectives uids, right?
so , no chance of bugging?
 
Back
Top