Postado Junho 20, 2014 10 anos Bom galera, estou voltando a ativa na área de otservers e também scripting, e queria uma ajuda pra resolver um problema do meu sistema de pet. O erro é esse: Acontece quando eu tento trazer meu pet de volta, depois que ele morre. Sei que tenho que criar um arquivo em creaturescripts, mas não estou conseguindo, alguém pode ajudar? Este é o script: local mtrs = { ["Rat"] = {hp = 1000, maxhp = 1000, corpse = 2813, chance = 100}, ["Rotworm"] = {hp = 1000, maxhp = 1000, corpse = 5967, chance = 100}, ["Skeleton"] = {hp = 1000, maxhp = 1000, corpse = 5972, chance = 100}, ["Dragon"] = {hp = 1000, maxhp = 1000, corpse = 3104, chance = 100}, ["Dragon Lord"] = {hp = 1000, maxhp = 1000, corpse = 5984, chance = 100}, } function onUse(cid, item, frompos, item2, topos) for pet_name, v in pairs(mtrs) do if item2.itemid == v.corpse then if math.random(0,100) <= v.chance then doPlayerSendTextMessage(cid, 27, "Você capturou um ".. pet_name .. ".") doRemoveItem(item2.uid, 1) doRemoveItem(item.uid, 1) local itemcatch = doPlayerAddItem(cid, 7632, 1) doItemSetAttribute(itemcatch, "namepet", pet_name) doItemSetAttribute(itemcatch, "description", "Contém um ".. pet_name ..".") doItemSetAttribute(itemcatch, "lifepet", v.hp) doItemSetAttribute(itemcatch, "maxlifepet", v.maxhp) else doPlayerSendTextMessage(cid, 27, "Falhou.") end end end return true end function onUse(cid, item, frompos, item2, topos) local health = tonumber(getItemAttribute(item.uid, "lifepet")) local mhp = tonumber(getItemAttribute(item.uid, "maxlifepet")) if health <= 0 then return doPlayerSendCancel(cid, "Esse pet esta morto.") end local pet_name = getItemAttribute(item.uid, "namepet") if item.itemid == 7632 then if not getTilePzInfo(getPlayerPosition(cid)) then if #getCreatureSummons(cid) < 1 then doTransformItem(item.uid, 7633) local summon = doSummonCreature(pet_name, getThingPos(cid)) doConvinceCreature(cid, summon) setCreatureMaxHealth(summon, mhp) doCreatureAddHealth(summon, mhp) doCreatureAddHealth(summon, health - mhp) doSendMagicEffect(getCreaturePosition(summon), 67) doCreatureSay(cid, "Vai, ".. pet_name .. "!", TALKTYPE_SAY) else doPlayerSendCancel(cid, "Você já sumonou um Pet.") end else doPlayerSendCancel(cid, "Você não pode estar em Protection Zone para sumonar seu Pet.") end elseif item.itemid == 7633 then local hp, maxhp = getCreatureHealth(getCreatureSummons(cid)[1]), getCreatureMaxHealth(getCreatureSummons(cid)[1]) if #getCreatureSummons(cid) >= 1 then doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 67) doRemoveCreature(getCreatureSummons(cid)[1]) doTransformItem(item.uid, 7632) doItemSetAttribute(item.uid, "lifepet", hp) doItemSetAttribute(item.uid, "maxlifepet", maxhp) doCreatureSay(cid, "Volta, " .. pet_name .. ".", TALKTYPE_SAY) end end return true end Desde já, obrigado. Editado Junho 20, 2014 10 anos por PsyMcKenzie (veja o histórico de edições)
Postado Junho 24, 2014 10 anos Solução mudei aquele fimzinho, troca por isso daqui: elseif item.itemid == 7633 then if #getCreatureSummons(cid) >= 1 then local hp, maxhp = getCreatureHealth(getCreatureSummons(cid)[1]), getCreatureMaxHealth(getCreatureSummons(cid)[1]) doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 67) doRemoveCreature(getCreatureSummons(cid)[1]) doTransformItem(item.uid, 7632) doItemSetAttribute(item.uid, "lifepet", hp) doItemSetAttribute(item.uid, "maxlifepet", maxhp) doCreatureSay(cid, "Volta, " .. pet_name .. ".", TALKTYPE_SAY) end end return true end
Postado Junho 24, 2014 10 anos coloquei a checagem da vida atual e total dentro da condição do numero de summons ser maior ou igual a 1. Daí não vai dar erro de "criatura não pode ser encontrada"
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.