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

Check monster name in area

†Cheetah†

New Member
Joined
Apr 2, 2020
Messages
2
Reaction score
0
Hello Goodnight.

How can I check the name of a monster in some area?

I have tried this but I can't

Lua:
local fromPos = {x=559, y=269, z=8}
local toPos = {x=574, y=282, z=8}
local exit = {x=550, y=232, z=8}

function onUse(cid, item, fromposition, itemEx, toPosition)
    local monster = "Morgaroth"
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                local posicion = getTopCreature({x=x,y=y,z=z}).uid
            end
        end
    end
    if (getCreatureName(posicion) == monster) then
        doSendMagicEffect(getPlayerPosition(cid), 39)
    end
    return true
end

I get this error

error.png
 
Last edited:
Solution
Hello Goodnight.

How can I check the name of a monster in some area?

I have tried this but I can't

Lua:
local fromPos = {x=559, y=269, z=8}
local toPos = {x=574, y=282, z=8}
local exit = {x=550, y=232, z=8}

function onUse(cid, item, fromposition, itemEx, toPosition)
    local monster = "Morgaroth"
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                local posicion = getTopCreature({x=x,y=y,z=z}).uid
            end
        end
    end
    if (getCreatureName(posicion) == monster) then
        doSendMagicEffect(getPlayerPosition(cid), 39)
    end
    return true
end

I get this error

View attachment 44926
Lua:
function onUse(cid, item, fromposition, itemEx...
Post automatically merged:

 
centerPosition is the center of the area you are testing
rangeX is the range, from the center, of the scan in the X axis
rangeY is the range, from the center, of the scan in the Y axis
Lua:
local centerPosition = Position(566, 275, 8)
local rangeX = 8
local rangeY = 7

local spectators = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
local spectator

for i = 1, #spectators do
    spectator = spectators[i]
  
    if spectator:isMonster() and spectator:getName() == "Morgaroth" then
        spectator:getPosition():sendMagicEffect(CONST_ME_SMALLCLOUDS)
    end
end
 
Hello Goodnight.

How can I check the name of a monster in some area?

I have tried this but I can't

Lua:
local fromPos = {x=559, y=269, z=8}
local toPos = {x=574, y=282, z=8}
local exit = {x=550, y=232, z=8}

function onUse(cid, item, fromposition, itemEx, toPosition)
    local monster = "Morgaroth"
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                local posicion = getTopCreature({x=x,y=y,z=z}).uid
            end
        end
    end
    if (getCreatureName(posicion) == monster) then
        doSendMagicEffect(getPlayerPosition(cid), 39)
    end
    return true
end

I get this error

View attachment 44926
Lua:
function onUse(cid, item, fromposition, itemEx, toPosition)
 local from = {x = 559, y = 269, z = 8}
    local to = {x = 574, y = 282, z = 8}
    local monster = "Morgaroth"
    for x = from.x, to.x do
        for y = from.y, to.y do
            for z = from.z, to.z do
                pos = {x = x, y = y, z = z, stackpos = 253}
                v = getThingfromPos(pos).uid
                if isMonster(v) and getCreatureName(v):lower() == monster:lower() then
                 doSendMagicEffect(getPlayerPosition(cid), 39)
                end
            end
        end
    end
end
 
Solution
Back
Top