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).
Add this tag on actions.xml
And the script:
Clean take 3~5 mins
it take 078ms
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).
Add this tag on actions.xml
Code:
<action itemid="2324" allowfaruse="1" event="script" value="clean.lua" />
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: