Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local name = "[PET] NIVEL MAXIMO"
local pet = getCreatureSummons(cid)
if #pet <= 0 then
doSummonMonster(cid, name)
setPlayerStorageValue(pet[1], 83712, 1)
else
for i = 1, #pet do
if getPlayerStorageValue(pet[i], 83712) == 1 then
doRemoveCreature(pet[i])
return true
end
end
doSummonMonster(cid, name)
setPlayerStorageValue(pet[#pet], 83712, 1)
end
return true
end
XML:
<action itemid="4864" event="script" value="simple_pet.lua"/>
the player summons the pet, and the pet does not attack the player, but the pet cannot be removed using the item
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local pet = getCreatureSummons(cid)
-- Verifica se o jogador já tem um pet invocado
if #pet > 0 then
return true -- Se já houver um pet invocado, não faça nada
end
-- Se não houver pet invocado, invoque um novo
local petName = "[PET] NIVEL MAXIMO"
local newPet = doSummonMonster(cid, petName)
if newPet then
-- Define uma storage value para indicar que esse pet pertence ao jogador
setPlayerStorageValue(newPet, 83712, getPlayerGUID(cid))
end
return true
end
function onUseItem(cid, item, fromPosition, itemEx, toPosition)
local pet = getCreatureSummons(cid)
-- Verifica se o jogador tem um pet invocado
if #pet > 0 then
-- Remove o pet do jogo
for _, creature in ipairs(pet) do
doRemoveCreature(creature)
end
-- Remove o item que invocou o pet
doRemoveItem(item.uid)
end
return true
end
Last edited: