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

monsterPosition not returning a position

() change
{} to these


nevermind, I'm not really sure..

normally I do it like this.. but I'm using 0.3.7
Code:
[10201] = {monsterName = "Demon", monsterPosition = {x = 1785, y = 1433, z = 7} },
 
() change
{} to these


nevermind, I'm not really sure..

normally I do it like this.. but I'm using 0.3.7
Code:
[10201] = {monsterName = "Demon", monsterPosition = {x = 1785, y = 1433, z = 7} },

Yeye, don't know why giving this error, XDDDD
 
Because Position is a table, the only difference is it has the metatable set in it, you can't concatenate it.
Source: https://github.com/otland/forgottenserver/blob/master/src/luascript.cpp#L870-L880

Change that print to:
Code:
print("Can't create the monster ".. b.monsterName .." on position x:" .. b.monsterPosition.x .. ", y: " .. b.monsterPosition.y .. ", z:" .. b.monsterPosition.z ..".")

Thank you for answering @MatheusMkalo, but I already did this XDD.
If you could take a look on the script below, I'll be appreciated it.

It is suppost to return true if >= 4 monsters on the area, but currently I'm getting a problem with isMonster().

Code:
local position = Position(b.monsterPosition.x, b.monsterPosition.y, b.monsterPosition.z)
local spec = Game.getSpectators(position, false, false, 3, 3, 3, 3)
local amount = 0
for _, s in pairs(spec) do
    amount = amount + 1
    if spec:isMonster() and amount >= 4 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sem mais que 4 monstros aqui, porra.")
        player:teleportTo(fromPosition)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        return true
    end
end
 
Thank you for answering @MatheusMkalo, but I already did this XDD.
If you could take a look on the script below, I'll be appreciated it.

It is suppost to return true if >= 4 monsters on the area, but currently I'm getting a problem with isMonster().

Code:
local position = Position(b.monsterPosition.x, b.monsterPosition.y, b.monsterPosition.z)
local spec = Game.getSpectators(position, false, false, 3, 3, 3, 3)
local amount = 0
for _, s in pairs(spec) do
    amount = amount + 1
    if spec:isMonster() and amount >= 4 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sem mais que 4 monstros aqui, porra.")
        player:teleportTo(fromPosition)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        return true
    end
end

Code:
local position = Position(b.monsterPosition.x, b.monsterPosition.y, b.monsterPosition.z)
local spec = Game.getSpectators(position, false, false, 3, 3, 3, 3)
local amount = 0
for _, s in pairs(spec) do
    if s:isMonster() then
        amount = amount + 1
    end
end

if amount >= 4 then
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sem mais que 4 monstros aqui, porra.")
    player:teleportTo(fromPosition)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end
 
Back
Top