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

Lua Game.createMonster no loot

leandroluck

New Member
Joined
Dec 24, 2010
Messages
104
Reaction score
1
Code:
function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster or targetMonster:getName():lower() ~= 'ghost' then
        return true
    end
    --clean arena of monsters
    local spectators, spectator = Game.getSpectators(Position(32800, 32829, 14), false, false, 15, 15, 15, 15)
    for i = 1, #spectators do
        spectator = spectators
        if spectator:isMonster() then
            spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
            spectator:remove()
        end
    end
    Game.createMonster('boss', Position(32800, 32829, 14))
    return true
end


Well it is working after the player kills the ghost appears the boss.

plus the boss is not giving loot is appearing a msg talking that the player can not open because he did not kill the boss

note: no have error in console
 
Last edited:
Solution
¬¬
Code:
local boss = Game.createMonster('boss', Position(32800, 32829, 14), true, true) -- you should force it, it have any item/wall etc the respawn can be blocked
if boss then
      boss:setReward(true)
end
¬¬
Code:
local boss = Game.createMonster('boss', Position(32800, 32829, 14), true, true) -- you should force it, it have any item/wall etc the respawn can be blocked
if boss then
      boss:setReward(true)
end
 
Solution
Code:
local boss = "name boss" -- boss name
local bossPositions = {
    Position(32800, 32829, 14), -- possition for random
    Position(32796, 32832, 14), -- possition for random
    Position(32804, 32834, 14), -- possition for random
    Position(32793, 32835, 14), -- possition for random
    Position(32809, 32830, 14), -- possition for random
    Position(32805, 32829, 14) -- possition for random
}


function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster or targetMonster:getName():lower() ~= 'namenormal monster' then
        return true
    end
    --clean arena of monsters
    local spectators, spectator = Game.getSpectators(Position(32800, 32829, 14), false, false, 15, 15, 15, 15)
    for i = 1, #spectators do
        spectator = spectators[i]
        if spectator:isMonster() then
            spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
            spectator:remove()
        end
    end

local boss = Game.createMonster('nameboss', bossPositions[math.random(#bossPositions)])
if boss then
      boss:setReward(true)
end
return true
end


@silveralol
Thank you, I made it ugly

had forgotten the setReward (true)
the script worked
 
Back
Top