local config = {
monster_name = "Lizard Snakecharmer",
max_summons = 1
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if (getTileInfo(getThingPos(cid)).protection) then
return (doPlayerSendCancel(cid, "You can't use this item in protection zone.") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF))
end
if (#getCreatureSummons(cid) >= config.max_summons) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
if (config.max_summons <= 1) then
doPlayerSendCancel(cid, "You can only summon max "..config.max_summons.."x "..config.monster_name..".")
else
doPlayerSendCancel(cid, "You can only summon max "..config.max_summons.."x "..config.monster_name.."s.")
end
else
local ret = doCreateMonster(config.monster_name, getThingPos(cid),true)
doSendMagicEffect(getThingPos(ret), CONST_ME_TELEPORT)
doConvinceCreature(cid, ret)
doRemoveItem(item.uid,1)
end
return true
end