function onUse(cid, item, frompos, item2, topos)
local pos = getCreaturePosition(cid)
if getPlayerItemCount(cid,12597) >= 1 then
doPlayerRemoveItem(cid, 12597, 1)
doCreateMonster("Lizard Snakecharmer", pos)
else
doPlayerSendCancel(cid, "Sorry, not possible.")
end
return true
end
<action itemid="12597" event="script" value="lizardsumm.lua"/>
<action itemid="12597" event="script" value="pet_summon.lua"/>
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
@UP
That script will create a wild monster and its badly made, you dont need to define the itemid when you already doing it in the xml and you dont need to put else if, they dont have the item, they wont be able to create so why put else?
----My Script----
I hope this will fulfill your needs!
First go to actions/actions.xml and paste the line below:
XML:<action itemid="12597" event="script" value="pet_summon.lua"/>
Now go to actions/scripts and create new lua and name it "pet_summon.lua" and paste the code below:
LUA: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
Enjoy!
Well, you need to make sure in the monster folder {Lizard Snakecharmer.xml} the <flag convinceable="1"/> and not 0.