Ir para conteúdo

Featured Replies

Postado

ola amigos eu tenho este sistema de pet... o erro é o seguinte..

quando eu deslogo o char com o pet acionado.. ao logar novamente eu perco o pet pq eu nao trouxe o pet pra poke bola antes de deslogar...

 

	<action itemid="21555" event="script" value="CatchPet.lua"/>
    <action itemid="21553;21554" event="script" value="VaiVolta.lua"/>

 

catchpet

local mtrs = {

                ["Rat"] = {hp = 100, maxhp = 100, corpse = 5964, chance = 100},
                ["Troll"] = {hp = 100, maxhp = 100, corpse = 5960, chance = 100},
                ["Wolf"] = {hp = 100, maxhp = 100, corpse = 5968, chance = 100},
                ["Vampire"] = {hp = 1000, maxhp = 1000, corpse = 5968, chance = 60},
                ["Rotworm"] = {hp = 100, maxhp = 100, corpse = 5967, chance = 100},
                ["Skeleton"] = {hp = 500, maxhp = 500, corpse = 5972, chance = 100},
                ["Demon skeleton"] = {hp = 1000, maxhp = 1000, corpse = 5963, chance = 80},
                ["Monk"] = {hp = 1000, maxhp = 1000, corpse = 6080, chance = 90},
                ["Dragon"] = {hp = 1500, maxhp = 1500, corpse = 5973, chance = 50},
                ["Demon"] = {hp = 8500, maxhp = 8500, corpse = 5995, chance = 10},
}

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 .. ".")
												doSendMagicEffect(getThingPos(cid), 135)
                                                doRemoveItem(item2.uid, 1)
                                                doRemoveItem(item.uid, 1)
                                                local itemcatch = doPlayerAddItem(cid, 21553, 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.")
												doSendMagicEffect(getThingPos(cid), 136)
												doRemoveItem(item.uid, 1)
												doRemoveItem(item2.uid, 1)
                                        end
                                end
                end
                return true
end

 

 

vaivolta

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 == 21553 then
        if not getTilePzInfo(getPlayerPosition(cid)) then
            if #getCreatureSummons(cid) < 1 then
                doTransformItem(item.uid, 21554)
                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 == 21554 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, 21553)
            doItemSetAttribute(item.uid, "lifepet", hp)
            doItemSetAttribute(item.uid, "maxlifepet", maxhp)
            doCreatureSay(cid, "Volta, " .. pet_name .. ".", TALKTYPE_SAY)
        end
    end

    return true
end

 

Postado

Esta é uma mensagem automática! Este tópico foi movido para a área correta.
Pedimos que você leia as regras do fórum.

Spoiler

This is an automated message! This topic has been moved to the correct area.
Please read the forum rules.

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Postado
Em 19/02/2017 ás 22:14, robi123 disse:

ola amigos eu tenho este sistema de pet... o erro é o seguinte..

quando eu deslogo o char com o pet acionado.. ao logar novamente eu perco o pet pq eu nao trouxe o pet pra poke bola antes de deslogar...

 


	<action itemid="21555" event="script" value="CatchPet.lua"/>
    <action itemid="21553;21554" event="script" value="VaiVolta.lua"/>

 

catchpet


local mtrs = {

                ["Rat"] = {hp = 100, maxhp = 100, corpse = 5964, chance = 100},
                ["Troll"] = {hp = 100, maxhp = 100, corpse = 5960, chance = 100},
                ["Wolf"] = {hp = 100, maxhp = 100, corpse = 5968, chance = 100},
                ["Vampire"] = {hp = 1000, maxhp = 1000, corpse = 5968, chance = 60},
                ["Rotworm"] = {hp = 100, maxhp = 100, corpse = 5967, chance = 100},
                ["Skeleton"] = {hp = 500, maxhp = 500, corpse = 5972, chance = 100},
                ["Demon skeleton"] = {hp = 1000, maxhp = 1000, corpse = 5963, chance = 80},
                ["Monk"] = {hp = 1000, maxhp = 1000, corpse = 6080, chance = 90},
                ["Dragon"] = {hp = 1500, maxhp = 1500, corpse = 5973, chance = 50},
                ["Demon"] = {hp = 8500, maxhp = 8500, corpse = 5995, chance = 10},
}

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 .. ".")
												doSendMagicEffect(getThingPos(cid), 135)
                                                doRemoveItem(item2.uid, 1)
                                                doRemoveItem(item.uid, 1)
                                                local itemcatch = doPlayerAddItem(cid, 21553, 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.")
												doSendMagicEffect(getThingPos(cid), 136)
												doRemoveItem(item.uid, 1)
												doRemoveItem(item2.uid, 1)
                                        end
                                end
                end
                return true
end

 

 

vaivolta


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 == 21553 then
        if not getTilePzInfo(getPlayerPosition(cid)) then
            if #getCreatureSummons(cid) < 1 then
                doTransformItem(item.uid, 21554)
                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 == 21554 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, 21553)
            doItemSetAttribute(item.uid, "lifepet", hp)
            doItemSetAttribute(item.uid, "maxlifepet", maxhp)
            doCreatureSay(cid, "Volta, " .. pet_name .. ".", TALKTYPE_SAY)
        end
    end

    return true
end

 

Voce adicionou todos creaturescripts certinho? manda o topico desse sistema ou poste-o completo

Postado
  • Autor

@Gustavo Ntos Eae Gustavo

 

eu desistalei agora este sistema pq nao consegui arrumar e coloquei outro aqui do TK, e nao deu este problema

vlw pela força ai

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo