demon088
#088 in the Horde
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.
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.
How can I solve this issue?
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
How can I solve this issue?