I have created a clean-function for lua. It is almost as fast as the source-clean, and it will not give errors when there is no tile on the area! It will only clean moveable items, and it will not remove creatures!
Why would you ever use this function when you already got it in source?
Well, first of all, source function dosent clean pz-zones, so this requires source edit.
Secondly, areas like temple and depot gets trashed maybe 10x faster than the rest of the map, so instead of cleaning the whole server every hour (which makes lag), you can use my function to clean only the depot and temple for I.E every 30 minutes, and clean the whole map every 3 hours!
Put this in your lib/function.lua
Then, you put the clean-function below the one you just added:
Hope it gets handy
Would'nt mind rep+
Why would you ever use this function when you already got it in source?
Well, first of all, source function dosent clean pz-zones, so this requires source edit.
Secondly, areas like temple and depot gets trashed maybe 10x faster than the rest of the map, so instead of cleaning the whole server every hour (which makes lag), you can use my function to clean only the depot and temple for I.E every 30 minutes, and clean the whole map every 3 hours!
Put this in your lib/function.lua
PHP:
function tileArea(fromPos, toPos, stack)
-- Area iterator by Colandus, edit by Tufte for tiles
local pos = {x=fromPos.x, y=fromPos.y-1, z=fromPos.z}
return function()
if (pos.y < toPos.y) then
pos.y = pos.y+1
elseif (pos.x <= toPos.x) then
pos.y = fromPos.y
pos.x = pos.x+1
else
pos.x = fromPos.x
pos.y = fromPos.y
pos.z = pos.z+1
end
if (pos.x <= toPos.x and pos.y <= toPos.y or pos.z < toPos.z) then
if (stack == nil) then
return pos
else
pos.stackpos = stack
return pos, getTileThingByPos(pos)
end
end
end
end
Then, you put the clean-function below the one you just added:
PHP:
function cleanArea(frompos, topos)
for pos, thing in tileArea(frompos, topos, 0) do
if thing.uid ~= 0 then
pos.stackpos = 255
while isCreature(getThingfromPos(pos).uid) ~= TRUE and getThingfromPos(pos).itemid > 0 and hasProperty(getThingfromPos(pos).uid, 6) == TRUE and getTileInfo(pos).house == FALSE do
if getThingfromPos(pos).type ~= 0 then
doRemoveItem(getThingfromPos(pos).uid, getThingfromPos(pos).type)
else
doRemoveItem(getThingfromPos(pos).uid, 1)
end
end
end
end
end
Hope it gets handy
Would'nt mind rep+
Last edited: