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

Clear certain items/monsters

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,015
Solutions
3
Reaction score
629
Location
Canada
I have a big quest room. It's full of trapped tiles but I want a system that will clear the whole room after a player exits (like the /r command but a controlled area and only certain objects and monsters). Maybe like when the player steps on the entrance tile, the room clears. So when they enter or exit, the room clears so it's not overloaded or obvious where traps are.
It's a perfect rectangle so if it's based on corner coordinates, it should be easy enough o.o
But I'm a little lost on how to do it ^_^
Rep for whoever helps, naturally.
 
Try:
To clean monsters
LUA:
local t = {}
 
for x = 100, 200 do
	for y = 100, 200 do
		local v = getTopCreature({x=x, y=y, z=7}).uid
		if isMonster(v) then
			table.insert(t, v)
		end
	end
end
 
for i = 1, #t do
	doRemoveCreature(t[i])
end
Credits for Cyko ^

For items
LUA:
local a = {}
 
for x = 100, 200 do
	for y = 100, 200 do
		local b = getThingfromPos({x=x, y=y, z=7, stackpos = 1}).uid
		if isInArray({itemstoremove??},b) then  ---- Put the items to remove xxxx,xxxx,xxxx,xxxx,xxxx
			table.insert(a, b)
		end
	end
end
 
for i = 1, #a do
	doRemoveItem(a[i])
end

Credits to Cyko too(I just made a small edit)
 
Last edited:
Just add it in the script u gonna use, if you gonna move to a tile and remove everything, then, use function onStepIn, and just put the areas there :<
 
Alrighty, I'll try it out thanks xD

Hm, monsters work, but items don't :S

Edit:

Monsters work, items don't and I also want it so that if a player is in the room, it won't clear the room. That would defeat the purpose of the quest o.o
 
Last edited:
Monsters work, items don't and I also want it so that if a player is in the room, it won't clear the room. That would defeat the purpose of the quest o.o
I thought I posted a similar piece of code recently.
http://otland.net/f16/arena-mortal-combat-112710/#post1119286
LUA:
		for x = from.x, to.x do
			for y = from.y, to.y do
				local v = getTopCreature({x=x, y=y, z=from.z}).uid
				if isPlayer(v) then
					return doCreatureSay(cid, 'There is already a team in the battle room.', TALKTYPE_ORANGE_1, false, cid)
				elseif isMonster(v) then
					table.insert(t, v)
				end
			end
		end
		for i = 1, #t do
			doRemoveCreature(t[i])
		end
 
And how about the item part? it doesn't work :S
Edit:
This is what I have atm. removes creatures if no players are in the room, doesn't remove if they are. Works great. Doesn't remove items. No error messages.
Code:
elseif (item.actionid == 2119 and isPlayer) then
		local t = {}
 
	for x = 6968, 6994 do
		for y = 2129, 2147 do
			local v = getTopCreature({x=x, y=y, z=9}).uid
				if isPlayer(v) then
					return doCreatureSay(cid, 'There is still someone inside the room.', TALKTYPE_ORANGE_1, false, cid)
				elseif isMonster(v) then
					table.insert(t, v)
				end
			end
		end
		for i = 1, #t do
			doRemoveCreature(t[i])
		end
 
	for i = 1, #t do
		doRemoveCreature(t[i])
	end

	local a = {}
 
	for x = 6968, 6994 do
		for y = 2129, 2147 do
			local b = getThingfromPos({x=x, y=y, z=9, stackpos = 1}).uid
			if isInArray({1506, 8505},b) then ---- Put the items to remove xxxx,xxxx,xxxx,xxxx,xxxx
				table.insert(a, b)
			end
		end
	end
 
	for i = 1, #a do
		doRemoveItem(a[i])
	end
		return true
		else
		return false
	end
 
Last edited:
LUA:
elseif isPlayer(cid) and item.actionid == 2119 then
	local t = {}
	for x = 6968, 6994 do
		for y = 2129, 2147 do
			local v = getTopCreature({x=x, y=y, z=9}).uid
			if isPlayer(v) then
				return doCreatureSay(cid, 'There is still someone inside the room.', TALKTYPE_ORANGE_1, false, cid)
			elseif isMonster(v) then
				table.insert(t, v)
			end
		end
	end

	for i = 1, #t do
		doRemoveCreature(t[i])
	end

	for x = 6968, 6994 do
		for y = 2129, 2147 do
			doCleanTile({x=x, y=y, z=9})
		end
	end

	return true
else
	return false
end
 
Last edited:
Back
Top