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

can not summon monsters keep getting error

Bloodhunter

New Member
Joined
Oct 7, 2008
Messages
22
Solutions
1
Reaction score
1
attempt to call method 'hasFlag' (a nil value)
stack traceback:
[C]: in function 'hasFlag'
 
Code tags please and could you clean up the indentation? I am sure it doesn't look like that in your script.
See the difference?
Code:
local variable = 1
 
idk what you mean but heres the file

Code:
function onCastSpell(creature, variant)

    if creature:getSkull() == SKULL_BLACK then

        creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)

        return false

    end



    local monsterName = variant:getString()

    local monsterType = MonsterType(monsterName)



    if not monsterType then

        creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)

        creature:getPosition():sendMagicEffect(CONST_ME_POFF)

        return false

    end



    if not creature:hasFlag(PlayerFlag_CanSummonAll) then

        if not monsterType:isSummonable() then

            creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)

            creature:getPosition():sendMagicEffect(CONST_ME_POFF)

            return false

        end



        if #creature:getSummons() >= 2 then

            creature:sendCancelMessage("You cannot summon more creatures.")

            creature:getPosition():sendMagicEffect(CONST_ME_POFF)

            return false

        end

    end



    local manaCost = monsterType:getManaCost()

    if creature:getMana() < manaCost and not creature:hasFlag(PlayerFlag_HasInfiniteMana) then

        creature:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)

        creature:getPosition():sendMagicEffect(CONST_ME_POFF)

        return false

    end



    local position = creature:getPosition()

    local summon = Game.createMonster(monsterName, position, true)

    if not summon then

        creature:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)

        position:sendMagicEffect(CONST_ME_POFF)

        return false

    end



    creature:addMana(-manaCost)

    creature:addManaSpent(manaCost)

    creature:addSummon(summon)

    position:sendMagicEffect(CONST_ME_MAGIC_BLUE)

    summon:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    return true

end
 

Attachments

Last edited by a moderator:
Back
Top