local areasToClear = {
["maincity"] = {
fromPosition = Position(2500, 2500, 7),
toPosition = Position(2550, 2550, 7)
},
["temple"] = {
fromPosition = Position(2600, 2500, 7),
toPosition = Position(2650, 2550, 7)
},
["entrance"] = {
fromPosition = Position(2500, 2600, 7),
toPosition = Position(2550, 2650, 7)
}
-- Add new areas as needed.
}
local function removeCreaturesInRange(fromPos, toPos)
for z = fromPos.z, toPos.z do
for y = fromPos.y, toPos.y do
for x = fromPos.x, toPos.x do
local tile = Tile(x, y, z)
if tile then
local creatures = tile:getCreatures()
for i = 1, tile:getCreatureCount() do
local creature = creatures[i]
if creature and creature:isMonster() then
creature:remove()
end
end
end
end
end
end
end
local function clearArea(player, areaName)
if not player:getGroup():getAccess() then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You do not have permission to use this command.")
return true
end
if player:getAccountType() < ACCOUNT_TYPE_GOD then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Your account type is not high enough to use this command.")
return false
end
local area = areasToClear[areaName]
if area then
removeCreaturesInRange(area.fromPosition, area.toPosition)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "All creatures in the " .. areaName .. " have been removed.")
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "The specified area does not exist.")
end
return false
end
local clear = TalkAction("/clear")
function clear.onSay(player, words, param)
if param and areasToClear[param] then
return clearArea(player, param)
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Please specify a valid area name.")
return false
end
end
clear:separator(" ")
clear:register()