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

TFS 1.X+ Clean Area

darcioantonio

www.adventurerpg.com.br
Joined
Jul 30, 2013
Messages
165
Solutions
1
Reaction score
4
Location
Brasil
Twitch
darcio_
YouTube
UCEXCOEw_dYchojHNz
TFS 1.2
Hi there, is there any script that cleans a certain map area?
frompos = {x = 967, y = 1029, z = 7}
topos = {x = 985, y = 1046, z = 7}
 
Last edited:
Made this with a lever id 1945, but you can use the core part of the script to see how it's done.

I'm almost sure that this will work, didn't test it.

Code:
local area = {
    fromPos = {x = , y = , z = },
    toPos = {x = , y = , z = }
}

function onUse(player, item, frompos, item2, topos)
if item.itemid == 1945 then
    for x = area.fromPos.x, area.toPos.x do
        for y = area.fromPos.y, area.toPos.y do
            for z = area.fromPos.z, area.toPos.z do
                local t = Tile(x, y, z)
                if t and t:getTopDownItem() then
                    for i = 255, 1, -1 do
                        if t:getTopDownItem() then
                            t:getTopDownItem():remove()
                        end
                    end
                end
            end
        end
    end
end
item:transform(item.itemid == 1946 and 1945 or 1946)
    return true
end
Remember to edit the coords
 
we were able to develop this script that removes specific items

Lua:
function onUse(cid, creature, player, item, fromPosition, target, toPosition, isHotkey)
  CleamAreaXY()
end

function CleamAreaXY()
  local ItensIDS = {1987, 18390, 2420, 2253, 3058, 3059, 3060, 1988, 2269, 2308, 2273, 2262, 7620, 2293,  2261, 2304,  2268, 2278, 8890, 2195, 2579, 2169, 2197}
  local p = {from = {x = 1252, y = 1002, z = 4}, to = {x = 1254, y = 1004, z = 4}}
  function isCleanAbleArea(pos)
    pos.stackpos = 0
    local tile = getThingfromPos(pos, false)
    if tile ~= 0 and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not isCreature(getTopCreature(pos).uid) then
      return true end end
      for x = p.from.x, p.to.x do
        for y = p.from.y, p.to.y do
          for z = p.from.z, p.to.z do
            for c = 0, 7 do
              local c = {x = x, y = y, z = c}
              if isCleanAbleArea(c) then
                local itens = Tile(c):getItems()
                for slot = 1, #itens do
                  for lista = 1, #ItensIDS do
                    if itens[slot]:getId() == ItensIDS[lista] then itens[slot]:remove() end
                  end
                end
              end
            end
          end
        end
      end
    end
 
we were able to develop this script that removes specific items

Lua:
function onUse(cid, creature, player, item, fromPosition, target, toPosition, isHotkey)
  CleamAreaXY()
end

function CleamAreaXY()
  local ItensIDS = {1987, 18390, 2420, 2253, 3058, 3059, 3060, 1988, 2269, 2308, 2273, 2262, 7620, 2293,  2261, 2304,  2268, 2278, 8890, 2195, 2579, 2169, 2197}
  local p = {from = {x = 1252, y = 1002, z = 4}, to = {x = 1254, y = 1004, z = 4}}
  function isCleanAbleArea(pos)
    pos.stackpos = 0
    local tile = getThingfromPos(pos, false)
    if tile ~= 0 and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not isCreature(getTopCreature(pos).uid) then
      return true end end
      for x = p.from.x, p.to.x do
        for y = p.from.y, p.to.y do
          for z = p.from.z, p.to.z do
            for c = 0, 7 do
              local c = {x = x, y = y, z = c}
              if isCleanAbleArea(c) then
                local itens = Tile(c):getItems()
                for slot = 1, #itens do
                  for lista = 1, #ItensIDS do
                    if itens[slot]:getId() == ItensIDS[lista] then itens[slot]:remove() end
                  end
                end
              end
            end
          end
        end
      end
    end
Oh, you didn't specify to clean certain items, mine will clean any item in the area :p
 
remove creatures and containers(corpses, bags etc..)

Code:
function cleanZone(frompos, topos, clean_creatures)
    for xx = frompos.x, topos.x do
        for yy = frompos.y, topos.y do
            local tile = Tile(Position(xx, yy, frompos.z))
            if tile then
                local items = tile:getItems()
                for _, item in pairs(items) do
                    local IType = ItemType(item:getId())
                    if IType:isContainer() then
                        item:remove()
                    end
                end

                if clean_creatures then
                    local c = tile:getTopCreature()
                    if c then
                        if c:isMonster() then
                            c:remove()
                        end
                    end
                end
            end
        end
    end
end

how to use:

Code:
cleanZone(fromPosition, toPosition, true)

cleanZone(Position(x,y,z), Position(x,y,z), true) -- true remove monsters

cleanZone({x=1,y=1,z=1}, {x=1,y=1,z=1}, false) -- false not remove monster
 
I think this could work out, if it does, you add or remove as many items as you want in itemIds variable.
Code:
local area = {
    fromPos = {x = , y = , z = },
    toPos = {x = , y = , z = }
}
local itemIds = {1987, 18390, 2420, 2253, 3058, 3059, 3060, 1988, 2269, 2308, 2273, 2262, 7620, 2293,  2261, 2304,  2268, 2278, 8890, 2195, 2579, 2169, 2197}

function onUse(player, item, frompos, item2, topos)
if item.itemid == 1945 then
    for x = area.fromPos.x, area.toPos.x do
        for y = area.fromPos.y, area.toPos.y do
            for z = area.fromPos.z, area.toPos.z do
                local t = Tile(x, y, z)
                if t and t:getTopDownItem() then
                    for i = 255, 1, -1 do
                        for _ = 1, #itemIds do
                            if t:getTopDownItem():getId() == itemIds[_] then
                                t:getTopDownItem():remove()
                            end
                        end
                    end
                end
            end
        end
    end
end
item:transform(item.itemid == 1946 and 1945 or 1946)
    return true
end
 
we were able to develop this script that removes specific items

Lua:
function onUse(cid, creature, player, item, fromPosition, target, toPosition, isHotkey)
  CleamAreaXY()
end

function CleamAreaXY()
  local ItensIDS = {1987, 18390, 2420, 2253, 3058, 3059, 3060, 1988, 2269, 2308, 2273, 2262, 7620, 2293,  2261, 2304,  2268, 2278, 8890, 2195, 2579, 2169, 2197}
  local p = {from = {x = 1252, y = 1002, z = 4}, to = {x = 1254, y = 1004, z = 4}}
  function isCleanAbleArea(pos)
    pos.stackpos = 0
    local tile = getThingfromPos(pos, false)
    if tile ~= 0 and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not isCreature(getTopCreature(pos).uid) then
      return true end end
      for x = p.from.x, p.to.x do
        for y = p.from.y, p.to.y do
          for z = p.from.z, p.to.z do
            for c = 0, 7 do
              local c = {x = x, y = y, z = c}
              if isCleanAbleArea(c) then
                local itens = Tile(c):getItems()
                for slot = 1, #itens do
                  for lista = 1, #ItensIDS do
                    if itens[slot]:getId() == ItensIDS[lista] then itens[slot]:remove() end
                  end
                end
              end
            end
          end
        end
      end
    end

hadouken-indentation.jpg
 
Consegui >:D


Lua:
local function LimparMapa()
  local configClean = {
    Map = {
      LS = {x = 1381, y = 1042, z = 6},   -- LIMIT NORT WEST
      LI = {x = 1390, y = 1050, z = 6}, -- LIMIT SUL EAST
    },
  }
  local ItensIDS = {2195, 2148, 7590} -- IDS FOR REMOVE
  for x = configClean.Map.LS.x, configClean.Map.LI.x do
    for y = configClean.Map.LS.y, configClean.Map.LI.y do
      for z = 1, 6 do
        for lista = 1, #ItensIDS do
          local tile = Tile(x, y, z)
          if tile then
            local field = tile:getItemById(ItensIDS[lista])
            if field then
              field:remove()
            end
          end
        end
      end
    end
  end
end
 
Back
Top