• 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 Help with summoning spell

demon088

#088 in the Horde
Joined
Jun 17, 2009
Messages
249
Solutions
3
Reaction score
30
Location
Hell
So long time ago I took this script from this forum, to be honest I don't remember the exact post or author, so I apologize about that.
Lua:
local config = {
    maxSummons = 1,
    summonName = "Warding Totem"
}
function onCastSpell(creature, var)
    local player = creature:getPlayer()
    if player == nil then
        return false
    end
    local playerPosition = player:getPosition()
    if #player:getSummons() > 0 then
            creature:sendCancelMessage("You cannot summon more warding totems.")
            creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    local monster = Game.createMonster(config.summonName, playerPosition, false, false)
    if not monster then -- If there is no room the summon the monster, lets force it!
        Game.createMonster(config.summonName, playerPosition, false, true)
    end
    monster:setMaster(player)
    return true
end
This script works summoning a limited amount of a selected monster, in this case I use it for druids summoning totems. The thing is that I found a problem with this script, whenever you summon this creature and there is no room, it summons a wild creature. This is a big problem, because it can be done to troll people within trainers and also is a bad idea when you are hunting creatures spamming fields.
anima.png
How can I solve this issue?
 
Solution
Lua:
if not monster then -- If there is no room the summon the monster, lets force it!
        monster = Game.createMonster(config.summonName, playerPosition, false, true)
end
Lua:
if not monster then -- If there is no room the summon the monster, lets force it!
        monster = Game.createMonster(config.summonName, playerPosition, false, true)
end
 
Solution
Lua:
if not monster then -- If there is no room the summon the monster, lets force it!
        monster = Game.createMonster(config.summonName, playerPosition, false, true)
end
If I remove that part, the spell will just summon a wild creature.
 
Back
Top