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

addEvent - Clean area = [SOLVED] (thx Azi)

Ezzam

New Member
Joined
Jan 16, 2008
Messages
213
Reaction score
2
Add this in your script after (example:)
PHP:
if item.itemid == 1945 then
  addEvent(CleanArea, 0)
end



Add this to the bottom of your script.

Code:
function CleanArea(startPos, endPos)
local startPos={x=32707, y=32345, z=7, stackpos=253}
local endPos={x=32725, y=32357, z=7, stackpos=253}
    local creatures = {monsters = 0, monsterNames = {}}
    for posX=startPos.x, endPos.x do
        for posY=startPos.y, endPos.y do
            for posZ=startPos.z, endPos.z do
                local check = getThingfromPos({x=posX, y=posY, z=posZ, stackpos=253})
                if isMonster(check.uid) == TRUE then
                    creatures.monsters = creatures.monsters+1
                    table.insert(creatures.monsterNames, getCreatureName(check.uid))
                    doRemoveCreature(check.uid)
                end
            end
        end
    end
    return creatures
end


Add rep++ to Azi to thank him for helping me create this script.
 
Last edited:
It's my function... :D
You can use it like or what you like:
PHP:
local starting={x=32707, y=32345, z=7, stackpos=253}
local ending={x=32725, y=32358, z=7, stackpos=253}
doPlayerSendTextMessage(cid, 22, 'Creature Clean completed! '..clean.players..' players and '..clean.monsters..' has been removed!')
and don't use addEvent, better is onThink ; )
PHP:
function CleanArea(startPos, endPos)
	local creatures = {players = 0, monsters = 0, monsterNames = {}, playerNames}
	for posX=startPos.x, endPos.x do
		for posY=startPos.y, endPos.y do
			for posZ=startPos.z, endPos.z do
				local check = getThingfromPos({x=posX, y=posY, z=posZ, stackpos=253})
				if isMonster(check.uid) == TRUE then
					creatures.monsters = creatures.monsters+1
					table.insert(creatures.monsterNames, getCreatureName(check.uid))
					doRemoveCreature(check.uid)
				elseif isPlayer(check.uid) == TRUE then
					creatures.players = creatures.players+1
					table.insert(creatures.playerNames, getCreatureName(check.uid))
					doRemoveCreature(check.uid)
				end
			end
		end
	end
	return creatures
end
 
Last edited:
Code:
data/movements/scripts/removegreenhornstone.lua:52: bad argument #1 to 'insert' (table expected, got nil)
 
Code:
data/movements/scripts/removegreenhornstone.lua:56: bad argument #1 to 'insert' (table expected, got nil)
(same error, do i have to add something to the code myself?)
 
without saving monster/players remove names:
PHP:
function CleanArea(startPos, endPos)
    local creatures = {players = 0, monsters = 0, monsterNames = {}, playerNames}
    for posX=startPos.x, endPos.x do
        for posY=startPos.y, endPos.y do
            for posZ=startPos.z, endPos.z do
                local check = getThingfromPos({x=posX, y=posY, z=posZ, stackpos=253})
                if isMonster(check.uid) == TRUE then
                    creatures.monsters = creatures.monsters+1
                    doRemoveCreature(check.uid)
                elseif isPlayer(check.uid) == TRUE then
                    creatures.players = creatures.players+1
                    doRemoveCreature(check.uid)
                end
            end
        end
    end
    return creatures
end
look it. ;d
 
dohs.png
 
Back
Top Bottom