Joriku
Working in the mines, need something?
Hi,
how can I destroy an item of id outside of x y z top, bottom positions?
Not sure if this would be done using an aid put onto the given item to the player, the point of this is if an player leaves, dies or logs out of area in one way or another. The item removes itself from the player's backpack.
Then second question would be, how would I kill monsters inside the same radius of the first item?
Just slay, not remove since if they're removed, spawners will go out of work.
Here are some functions of an arena script I use to delete/reset if it helps with the process
how can I destroy an item of id outside of x y z top, bottom positions?
Not sure if this would be done using an aid put onto the given item to the player, the point of this is if an player leaves, dies or logs out of area in one way or another. The item removes itself from the player's backpack.
Then second question would be, how would I kill monsters inside the same radius of the first item?
Just slay, not remove since if they're removed, spawners will go out of work.
Here are some functions of an arena script I use to delete/reset if it helps with the process
LUA:
-- Outdated functions but works, remove mobs + players
local function doRemoveMonsterFromArea(fromPos, toPos)
for _x = fromPos.x, toPos.x do
for _y = fromPos.y, toPos.y do
for _z = fromPos.z, toPos.z do
local creature = getTopCreature({x = _x, y = _y, z = _z})
if creature ~= nil then
if isMonster(creature.uid) then
doRemoveCreature(creature.uid)
--print("There's a creature, removing it..")
elseif isPlayer(creature.uid) then
local exitPosition = Position(1199, 888, 7) -- Exit position
local specs = Game.getSpectators(Position(1134, 830, 4), false, false, 20, 20, 20, 20) -- Radius of center square of arena
for _, spec in ipairs(specs) do
if spec:isPlayer() then
spec:teleportTo(exitPosition)
end
end
--print("There's a player or more, teleporting them out of the boss room..")
end
else
--print("No creature found at position:", _x, _y, _z)
end
end
end
end
return false
end
-- Check for monsters in arena
local function isMonstersInsideArena()
for x = config.specPos.from.x, config.specPos.to.x do
for y = config.specPos.from.y, config.specPos.to.y do
for z = config.specPos.from.z, config.specPos.to.z do
local tile = Tile(Position(x, y, z))
local creatures = tile:getCreatures()
if creatures then
for _, creature in ipairs(creatures) do
if creature:isMonster() then
return true
end
end
end
end
end
end
return false
end
-- Check for players in arena
local function isPlayerInArena()
for x = config.specPos.from.x, config.specPos.to.x do
for y = config.specPos.from.y, config.specPos.to.y do
for z = config.specPos.from.z, config.specPos.to.z do
local tile = Tile(Position(x, y, z))
local creatures = tile:getCreatures()
if creatures then
for _, creature in ipairs(creatures) do
if creature:isPlayer() then
return true
end
end
end
end
end
end
return false
end