• 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 Cleaning broom 2.0

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
Well TFS now got 2~3 mins to clean a map of 15MB (in old times [0.3.4] it was 1~5 seconds)

So to avoid the long cleans i created this script to clean the server.

This broom can be used ONLY by CM (group 4, or edit) and clean in area and delete creatures (or configure).

limped.png

Add this tag on actions.xml
Code:
<action itemid="2324" allowfaruse="1" event="script" value="clean.lua" />
And the script:
Lua:
---Cleaning  broom by mock
local removeCreature = true
local maxStackpos = 255
local minStackpos = 1
function cleanSqm(Itempos) --- By mock the bear
	doSendMagicEffect(Itempos,36)
	Itempos.stackpos = 255
	local Item = getThingfromPos(Itempos,false)
	if (removeCreature and isCreature(Item.uid)) then
		doSendAnimatedText(Itempos,"Creature", TEXTCOLOR_DARKRED)
		if Item.uid ~= cid and not isPlayer(Item.uid) or getPlayerGroupId(Item.uid) == 1 then
			doRemoveCreature(Item.uid)
		end
	end
	for stack=-maxStackpos,minStackpos do
		Itempos.stackpos = stack*-1
		if Itempos.stackpos == 0 then break end
		local id = getThingfromPos(Itempos)
		if id.itemid > 0 and id.uid > 0 and not isCreature(id.uid) then
			if isMoveable(id.uid) then
				doRemoveItem(id.uid,-1)
			end
		end
	end
end
function executeInArea(pos, area,cmd,...)--by Nord and Mock
	local center = {}
	center.y = math.floor(#area/2)+1
	for y = 1, #area do
		for x = 1, #area[y] do
			local number = area[y][x]
			if number > 0 then
				center.x = math.floor(table.getn(area[y])/2)+1
				local pos = {x = pos.x + x - center.x, y = pos.y + y - center.y, z = pos.z}
				if type(cmd) == 'string' then
					local b = _G
					b.pos = pos
					local f = assert(loadstring(cmd))
					setfenv(f, b)
					f(pos,...)
				elseif type(cmd) == 'function' then
					cmd(pos,...)
				end
			end
		end
	end
end
function onUse(cid, item, frompos, item2, topos)  --- By mock the bear
	if getPlayerAccess(cid) >= 4 then
		executeInArea({x=topos.x,y=topos.y,z=topos.z}, {
		{0,0,0,1,0,0,0},
		{0,0,1,1,1,0,0},
		{0,1,1,1,1,1,0},
		{1,1,1,1,1,1,1},
		{0,1,1,1,1,1,0},
		{0,0,1,1,1,1,0},
		{0,0,0,1,0,0,0},
		},cleanSqm)
		return true
	end
	return false
end

Clean take 3~5 mins
it take 078ms
 
Last edited:
ehm I think TFS already has one, or two
well it's a command, but anyways great job :D
 
Debug mode:
function onUse(cid, item, frompos, item2, topos)
local start = os.clock()
doPlayerSendTextMessage(cid,25,'Started at: '..start..' = 0')
if getPlayerAccess(cid) >= 4 then
executeInArea({x=topos.x,y=topos.y,z=topos.z}, {
{0,0,0,1,0,0,0},
{0,0,1,1,1,0,0},
{0,1,1,1,1,1,0},
{1,1,1,1,1,1,1},
{0,1,1,1,1,1,0},
{0,0,1,1,1,1,0},
{0,0,0,1,0,0,0},
},cleanSqm)
doPlayerSendTextMessage(cid,25,'Finished at: '..os.clock()..' delay: '..os.clock()-start..' seconds.')
return true
end

return false
end
16:13 Started at: 13459.748 = 0
16:13 Finished at: 13459.826 delay: 0.078000000001339 seconds.
0.78 seconds (078 ms) Using stackpos 255 to 1
 
"Mock, forgive them; for they know not what they do."
 
it takes you 2~3 mins WITH WORLD CLEAN? :eek:

Anyways, nice script as always :).

Wow slow comp? takes 30sec on an rl map for me >,<


@topic, Nice script, Nice when the player throw out stuffs, Boring using clean rune, I will add a random effect, Thanks.
 
Well TFS now got 2~3 mins to clean a map of 15MB (in old times [0.3.4] it was 1~5 seconds)

So to avoid the long cleans i created this script to clean the server.

This broom can be used ONLY by CM (group 4, or edit) and clean in area and delete creatures (or configure).
I guess so
 
Back
Top