KaboFlow 54 Postado Abril 3, 2021 Share Postado Abril 3, 2021 que cura metade da vida do pokémon uma poção que cura em% exemplo usar a poção cura você em 50% da vida do pokémon Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/ Compartilhar em outros sites More sharing options...
0 Yan Oliveira 214 Postado Abril 3, 2021 Share Postado Abril 3, 2021 4 minutos atrás, KaboFlow disse: sim com tempo em 3min Troque o código por esse: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end percent = percent / 100 doCreatureAddHealth(cid, percent > 0 and math.floor(percent * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } local storage = 47898 -- STORAGE PARA USAR NOVAMENTE A POTION APÓS O TEMPO DO VALOR DA VARIÁVEL MINUTOS local minutos = 3 -- MINUTOS PARA USAR A POTION NOVAMENTE ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) if getPlayerStorageValue(cid, storage) <= os.time() then local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getCreatureHealth(pokemon) == getCreatureMaxHealth(pokemon) then return doPlayerSendCancel(cid, "The health of your pokémon already is full.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) setPlayerStorageValue(cid, storage, os.time() + (60 * minutos)) return true else return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to wait " .. minutos .. " minutes to use the potion again.") end end Criei uma variável minutos para poder definir outro valor caso queira mudar futuramente, mas deixei 3 por padrão. KaboFlow reagiu a isso 1 Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764930 Compartilhar em outros sites More sharing options...
0 Yan Oliveira 214 Postado Abril 3, 2021 Share Postado Abril 3, 2021 (editado) 13 minutos atrás, KaboFlow disse: Versão do Servidor: TFS - 0.3.4 Tipo de Script: actions Código: Mostrar conteúdo oculto que cura metade da vida do pokémon uma poção que cura em% exemplo usar a poção cura você em 50% da vida do pokémon Adicione esse script no seu arquivo.lua de potions: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end percent = percent / 100 doCreatureAddHealth(cid, health > 0 and math.floor(health * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) return true end E na tabela de potions mude o Id no índice da tabela, e a porcentagem e efeito nos campos da tabela. Editado Abril 3, 2021 por Yan18 Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764918 Compartilhar em outros sites More sharing options...
0 KaboFlow 54 Postado Abril 3, 2021 Autor Share Postado Abril 3, 2021 5 minutos atrás, Yan18 disse: Adicione esse script no seu arquivo.lua de potions: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end percent = percent / 100 doCreatureAddHealth(cid, health > 0 and math.floor(health * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) return true end E na tabela de potions mude o Id no índice da tabela, e a porcentagem e efeito nos campos da tabela. [02/04/2021 22:13:35] [Error - Action Interface] [02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:onUse [02/04/2021 22:13:35] Description: [02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:14: attempt to compare number with nil [02/04/2021 22:13:35] stack traceback: [02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:14: in function 'HealHealthPercent' [02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:54: in function <data/actions/scripts/potion/potion.lua:31> não cura nada Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764919 Compartilhar em outros sites More sharing options...
0 Yan Oliveira 214 Postado Abril 3, 2021 Share Postado Abril 3, 2021 (editado) 2 minutos atrás, KaboFlow disse: [02/04/2021 22:13:35] [Error - Action Interface] [02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:onUse [02/04/2021 22:13:35] Description: [02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:14: attempt to compare number with nil [02/04/2021 22:13:35] stack traceback: [02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:14: in function 'HealHealthPercent' [02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:54: in function <data/actions/scripts/potion/potion.lua:31> não cura nada De tanto usar parâmetro "health" no outro script de potions acabei colocando ele rsrs. Troque o código por esse: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end percent = percent / 100 doCreatureAddHealth(cid, health > 0 and math.floor(percent * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) return true end Editado Abril 3, 2021 por Yan18 Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764920 Compartilhar em outros sites More sharing options...
0 KaboFlow 54 Postado Abril 3, 2021 Autor Share Postado Abril 3, 2021 5 minutos atrás, Yan18 disse: De tanto usar parâmetro "health" no outro script de potions acabei colocando ele rsrs. Troque o código por esse: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end percent = percent / 100 doCreatureAddHealth(cid, health > 0 and math.floor(percent * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) return true end [02/04/2021 22:22:34] [Error - Action Interface] [02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:onUse [02/04/2021 22:22:34] Description: [02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:14: attempt to compare number with nil [02/04/2021 22:22:34] stack traceback: [02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:14: in function 'HealHealthPercent' [02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:54: in function <data/actions/scripts/potion/potion.lua:31> mismo error Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764921 Compartilhar em outros sites More sharing options...
0 Yan Oliveira 214 Postado Abril 3, 2021 Share Postado Abril 3, 2021 Agora, KaboFlow disse: [02/04/2021 22:22:34] [Error - Action Interface] [02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:onUse [02/04/2021 22:22:34] Description: [02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:14: attempt to compare number with nil [02/04/2021 22:22:34] stack traceback: [02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:14: in function 'HealHealthPercent' [02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:54: in function <data/actions/scripts/potion/potion.lua:31> mismo error É que no operador ternário eu chamei duas vezes e só mudei uma. Agora é para funcionar: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end percent = percent / 100 doCreatureAddHealth(cid, percent > 0 and math.floor(percent * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) return true end Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764922 Compartilhar em outros sites More sharing options...
0 KaboFlow 54 Postado Abril 3, 2021 Autor Share Postado Abril 3, 2021 2 minutos atrás, Yan18 disse: É que no operador ternário eu chamei duas vezes e só mudei uma. Agora é para funcionar: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end percent = percent / 100 doCreatureAddHealth(cid, percent > 0 and math.floor(percent * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) return true end [02/04/2021 22:26:37] [Error - Action Interface] [02/04/2021 22:26:37] data/actions/scripts/potion/potion.lua:onUse [02/04/2021 22:26:37] Description: [02/04/2021 22:26:37] (luaDoPlayerSendCancel) Player not found Eu fico agora se você puxar esse erro ocorre quando o Pokémon está cheio de vida Não sei porque mas já fico ... Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764923 Compartilhar em outros sites More sharing options...
0 Yan Oliveira 214 Postado Abril 3, 2021 Share Postado Abril 3, 2021 Agora, KaboFlow disse: [02/04/2021 22:26:37] [Error - Action Interface] [02/04/2021 22:26:37] data/actions/scripts/potion/potion.lua:onUse [02/04/2021 22:26:37] Description: [02/04/2021 22:26:37] (luaDoPlayerSendCancel) Player not found Eu fico agora se você puxar esse erro ocorre quando o Pokémon está cheio de vida Não sei porque mas já fico ... Não entendi, você fica com a vida cheia ao usar a potion? Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764924 Compartilhar em outros sites More sharing options...
0 KaboFlow 54 Postado Abril 3, 2021 Autor Share Postado Abril 3, 2021 3 minutos atrás, Yan18 disse: Não entendi, você fica com a vida cheia ao usar a potion? nada nada que se funcionar eu fico o que acontece se o pokémon estiver 100% e tento usar a poção dá aquele erro Antes que eu esqueça, eu poderia ter esfriado? Ao usar a poção, você tem que esperar 3 minutos para usá-la novamente? Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764925 Compartilhar em outros sites More sharing options...
0 Yan Oliveira 214 Postado Abril 3, 2021 Share Postado Abril 3, 2021 1 minuto atrás, KaboFlow disse: nada nada que se funcionar eu fico o que acontece se o pokémon estiver 100% e tento usar a poção dá aquele erro Estranho, mas troque o código por esse: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end percent = percent / 100 doCreatureAddHealth(cid, percent > 0 and math.floor(percent * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getCreatureHealth(pokemon) == getCreatureMaxHealth(pokemon) then return doPlayerSendCancel(cid, "The health of your pokémon already is full.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) return true end Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764926 Compartilhar em outros sites More sharing options...
0 KaboFlow 54 Postado Abril 3, 2021 Autor Share Postado Abril 3, 2021 1 minuto atrás, Yan18 disse: Estranho, mas troque o código por esse: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end percent = percent / 100 doCreatureAddHealth(cid, percent > 0 and math.floor(percent * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getCreatureHealth(pokemon) == getCreatureMaxHealth(pokemon) then return doPlayerSendCancel(cid, "The health of your pokémon already is full.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) return true end Antes que eu esqueça, eu poderia ter esfriado? Ao usar a poção, você tem que esperar 3 minutos para usá-la novamente? perfect Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764927 Compartilhar em outros sites More sharing options...
0 Yan Oliveira 214 Postado Abril 3, 2021 Share Postado Abril 3, 2021 (editado) 1 minuto atrás, KaboFlow disse: Antes que eu esqueça, eu poderia ter esfriado? Ao usar a poção, você tem que esperar 3 minutos para usá-la novamente? Você não comentou nada sobre ter que esperar um determinado tempo para usar novamente. Também não coloquei porque é uso com efeito único. Você quer que tenha tempo para usar novamente? No caso 3 minutos? Editado Abril 3, 2021 por Yan18 Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764928 Compartilhar em outros sites More sharing options...
0 KaboFlow 54 Postado Abril 3, 2021 Autor Share Postado Abril 3, 2021 2 minutos atrás, Yan18 disse: Você não comentou nada sobre ter que esperar um determinado tempo para usar novamente. Também não coloquei porque é uso com efeito único. Você quer que tenha tempo para usar novamente? No caso 3 minutos? sim com tempo em 3min Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764929 Compartilhar em outros sites More sharing options...
0 KaboFlow 54 Postado Abril 3, 2021 Autor Share Postado Abril 3, 2021 2 minutos atrás, Yan18 disse: Troque o código por esse: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end percent = percent / 100 doCreatureAddHealth(cid, percent > 0 and math.floor(percent * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } local storage = 47898 -- STORAGE PARA USAR NOVAMENTE A POTION APÓS O TEMPO DO VALOR DA VARIÁVEL MINUTOS local minutos = 3 -- MINUTOS PARA USAR A POTION NOVAMENTE ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) if getPlayerStorageValue(cid, storage) <= os.time() then local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getCreatureHealth(pokemon) == getCreatureMaxHealth(pokemon) then return doPlayerSendCancel(cid, "The health of your pokémon already is full.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) setPlayerStorageValue(cid, storage, os.time() + (60 * minutos)) return true else return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to wait " .. minutos .. " minutes to use the potion again.") end end Criei uma variável minutos para poder definir outro valor caso queira mudar futuramente, mas deixei 3 por padrão. 22:50 You need to wait 3 minutes to use the potion again. obrigado este tópico fica Eu gostaria que você checasse o outro. Estou aqui obrigado eles podem fechar o tópico Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764931 Compartilhar em outros sites More sharing options...
0 Yan Oliveira 214 Postado Abril 3, 2021 Share Postado Abril 3, 2021 11 horas atrás, KaboFlow disse: 22:50 You need to wait 3 minutes to use the potion again. obrigado este tópico fica Eu gostaria que você checasse o outro. Estou aqui obrigado eles podem fechar o tópico Então funcionou certinho né? Link para o comentário https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/#findComment-1764933 Compartilhar em outros sites More sharing options...
Pergunta
KaboFlow 54
que cura metade da vida do pokémon
uma poção que cura em%
exemplo
usar a poção cura você em 50% da vida do pokémon
Link para o comentário
https://xtibia.com/forum/topic/252939-potion-de-pokemon-que-cura-metade-da-vida-do-pok%C3%A9mon/Compartilhar em outros sites
18 respostass a esta questão
Posts Recomendados