Ir para conteúdo
  • Cadastre-se

(Resolvido)Ajuda simples de sistema de PET


Ir para solução Resolvido por Vodkart,

Posts Recomendados

Bom dia, Boa Tarde e Boa noite galera tudo bem ?, estou com um simples problema. gostaria que o pet depois que morresse levaria 1 minuto para q a pessoa pudesse usa o item para invocar ele novamente, alguem poderia me ajudar PF ????

  Citar

 

Mostrar mais  

 

Você tem o código disponível? Se tiver publique-o aqui: 

 

 

function onUse(cid, item, frompos, item2, topos)

local dolls = {
[2155] = {pet = "Pet Dalmata"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR
[2277] = {pet = "Pet Bode"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR

}

local go = dolls[item.itemid]
local summon = getCreatureSummons(cid)
local waittime = 60 -- Tempo de exhaustion em segundos
local strtime = 6660666 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...

if exhaustion.check(cid, strtime) then
doPlayerSendCancel(cid, "Aguarde " .. exhaustion.get(cid, strtime) .. " segundos para usar esse item novemente.")
return true
end 
---------------------------------------------------
if not (getTilePzInfo(getCreaturePosition(cid))) then
if #summon >= 1 then
for _, pid in ipairs(summon) do
doRemoveCreature(pid)
doCreatureSay(cid, ""..go.pet..", Recuar!", TALKTYPE_ORANGE_1)    -- MENSAGEM AO REMOVER O PET
exhaustion.set(cid, strtime, waittime)      -- checar time
end
return true
end

if item.itemid == 2155 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendAnimatedText(getPlayerPosition(cid), "!!!", 180)
end
if item.itemid == 2277 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendAnimatedText(getPlayerPosition(cid), "!!!", 180)
end 


else
doPlayerSendTextMessage(cid, 19, "Voce nao pode sumonar seu PET em Protect Zone!")
doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
return true
end
end


 

 

 

 

Editado por Capitao wyz (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • Capitao wyz mudou o título para Ajuda simples de sistema de PET

function onUse(cid, item, frompos, item2, topos)

local exstorage = 45718 
local time = 0*60

    if exhaustion.check(cid, exstorage) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Você precisa esperar antes de usar novamente.")
        return TRUE
    end

local dolls = {
[2155] = {pet = "Pet Dalmata"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR
[2277] = {pet = "Pet Bode"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR

}

local go = dolls[item.itemid]
local summon = getCreatureSummons(cid)
local waittime = 60 -- Tempo de exhaustion em segundos
local strtime = 6660666 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...

if exhaustion.check(cid, strtime) then
doPlayerSendCancel(cid, "Aguarde " .. exhaustion.get(cid, strtime) .. " segundos para usar esse item novemente.")
return true
end 
---------------------------------------------------
if not (getTilePzInfo(getCreaturePosition(cid))) then
if #summon >= 1 then
for _, pid in ipairs(summon) do
doRemoveCreature(pid)
doCreatureSay(cid, ""..go.pet..", Recuar!", TALKTYPE_ORANGE_1)    -- MENSAGEM AO REMOVER O PET
exhaustion.set(cid, strtime, waittime)      -- checar time
end
return true
end

if item.itemid == 2155 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendAnimatedText(getPlayerPosition(cid), "!!!", 180)
end
if item.itemid == 2277 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendAnimatedText(getPlayerPosition(cid), "!!!", 180)
end 


else
doPlayerSendTextMessage(cid, 19, "Voce nao pode sumonar seu PET em Protect Zone!")
doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
return true
end
end

Link para o post
Compartilhar em outros sites
  Em 24/02/2022 em 01:45, Encrypton disse:

function onUse(cid, item, frompos, item2, topos)

local exstorage = 45718 
local time = 0*60

    if exhaustion.check(cid, exstorage) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Você precisa esperar antes de usar novamente.")
        return TRUE
    end

local dolls = {
[2155] = {pet = "Pet Dalmata"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR
[2277] = {pet = "Pet Bode"}, -- ID DO ITEM E NOME DO MONSTRO QUE IRÁ SUMONAR

}

local go = dolls[item.itemid]
local summon = getCreatureSummons(cid)
local waittime = 60 -- Tempo de exhaustion em segundos
local strtime = 6660666 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...

if exhaustion.check(cid, strtime) then
doPlayerSendCancel(cid, "Aguarde " .. exhaustion.get(cid, strtime) .. " segundos para usar esse item novemente.")
return true
end 
---------------------------------------------------
if not (getTilePzInfo(getCreaturePosition(cid))) then
if #summon >= 1 then
for _, pid in ipairs(summon) do
doRemoveCreature(pid)
doCreatureSay(cid, ""..go.pet..", Recuar!", TALKTYPE_ORANGE_1)    -- MENSAGEM AO REMOVER O PET
exhaustion.set(cid, strtime, waittime)      -- checar time
end
return true
end

if item.itemid == 2155 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendAnimatedText(getPlayerPosition(cid), "!!!", 180)
end
if item.itemid == 2277 then              -- ID DO ITEM 
doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)      -- MENSAGEM AO SUMONAR O PET
doSendAnimatedText(getPlayerPosition(cid), "!!!", 180)
end 


else
doPlayerSendTextMessage(cid, 19, "Voce nao pode sumonar seu PET em Protect Zone!")
doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
return true
end
end

Mostrar mais  

 

Ola boa noite ainda estou com o mesmo problema, consigo sumonar mesmo depois que o pet  morre  :[ OBRIGADO PELA TENTATIVA !

Link para o post
Compartilhar em outros sites

tem que criar um evento de onDeath no pet, registrar no xml do monstro(pet) e ao morrer identificar de quem é o pet e ai sim dar o tempo de espera para o dono...

vodkart_logo.png

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

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
  Em 24/02/2022 em 16:32, Vodkart disse:

tem que criar um evento de onDeath no pet, registrar no xml do monstro(pet) e ao morrer identificar de quem é o pet e ai sim dar o tempo de espera para o dono...

Mostrar mais  

Ola boa tarde, nao querendo abusar mas poderia me ajudar fazendo isso pra min pf ?

Link para o post
Compartilhar em outros sites
  • Solução

CREATURESCRIPT

 

 

mortepet.lua

function isPetMonster(cid)
    return getCreatureMaster(cid) == 0 and false or isPlayer(getCreatureMaster(cid))
end
function onDeath(cid, corpse, deathList)
    if not isPetMonster(cid) then
        return true
    end
    local waittime = 60 -- Tempo de exhaustion em segundos
    local strtime = 6660666 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...
    local master = getCreatureMaster(cid)
    doPlayerSendTextMessage(master, MESSAGE_EVENT_ADVANCE, "Your pet is dead.")
    exhaustion.set(master, strtime, waittime)
    return true
end


TAG

<event type="death" name="MortePet" event="script" value="mortepet.lua"/>


No arquivo XML dos monstros que serão pets:

 

       <script>
               <event name="MortePet"/>
       </script>

 

vodkart_logo.png

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

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
  Em 24/02/2022 em 18:57, Vodkart disse:

CREATURESCRIPT

 

 

mortepet.lua

function isPetMonster(cid)
    return getCreatureMaster(cid) == 0 and false or isPlayer(getCreatureMaster(cid))
end
function onDeath(cid, corpse, deathList)
    if not isPetMonster(cid) then
        return true
    end
    local waittime = 60 -- Tempo de exhaustion em segundos
    local strtime = 6660666 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...
    local master = getCreatureMaster(cid)
    doPlayerSendTextMessage(master, MESSAGE_EVENT_ADVANCE, "Your pet is dead.")
    exhaustion.set(master, strtime, waittime)
    return true
end


TAG

<event type="death" name="MortePet" event="script" value="mortepet.lua"/>


No arquivo XML dos monstros que serão pets:

 

       <script>
               <event name="MortePet"/>
       </script>

 

Mostrar mais  

Cara perfeito, muito obrigado pela atençao  ajudou muito s2

Link para o post
Compartilhar em outros sites
  • 4 weeks later...
  Em 24/02/2022 em 18:57, Vodkart disse:

CREATURESCRIPT

 

 

mortepet.lua

function isPetMonster(cid)
    return getCreatureMaster(cid) == 0 and false or isPlayer(getCreatureMaster(cid))
end
function onDeath(cid, corpse, deathList)
    if not isPetMonster(cid) then
        return true
    end
    local waittime = 60 -- Tempo de exhaustion em segundos
    local strtime = 6660666 -- Storage, nunca usar a mesma em outra Script do mesmo tipo. Ex: mesmo creaturescript, mesmo action e etc...
    local master = getCreatureMaster(cid)
    doPlayerSendTextMessage(master, MESSAGE_EVENT_ADVANCE, "Your pet is dead.")
    exhaustion.set(master, strtime, waittime)
    return true
end


TAG

<event type="death" name="MortePet" event="script" value="mortepet.lua"/>


No arquivo XML dos monstros que serão pets:

 

       <script>
               <event name="MortePet"/>
       </script>

 

Expand   Mostrar mais  

 

Fiz da mesma forma que você falou só que quando o pet morre aparece a mensagem Your pet is dead, porem eu posso soltar ele a qualquer momento sem precisar esperar o tempo do script, já troquei a storage para testar .. tfs 0.4 da um help ai?

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96836
    Tópicos
    519589
    Posts
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo