Ir para conteúdo

Yan Oliveira

Moderador
  • Total de itens

    2221
  • Registro em

  • Última visita

  • Dias Ganhos

    60

Tudo que Yan Oliveira postou

  1. Yan Oliveira

    Revive Com Tempo

    Troque o código por esse: local level = 200 -- LEVEL MÍNIMO PARA USAR O REVIVE local storage_time = 68789 -- STORAGE PARA VERIFICAR O TEMPO PARA USAR O REVIVE local minutes = 10 -- MINUTOS PARA USAR O REVIVE local message_color = MESSAGE_STATUS_CONSOLE_BLUE -- COR DO TEXTO --------------- CÓDIGO --------------- function onUse(cid, item, frompos, item2, topos) if getPlayerLevel(cid) < level then doPlayerSendCancel(cid, "You need to be at least level " .. level .. " to use this revive.") return doPlayerSendTextMessage(cid, message_color, "You need to be at least level " .. level .. " to use this revive.") else if getPlayerStorageValue(cid, storage_time) <= os.time() then setPlayerStorageValue(cid, 8422, 0) setPlayerStorageValue(cid, 23254, 50) if isCreature(item2.uid) then return doPlayerSendCancel(cid, "You can only use revive in pokeballs!") end if isPlayer(item2.uid) then return doPlayerSendCancel(cid, "You cant use potions on wild pokemons.") end local x = pokeballs[getPokeballType(item2.itemid)] if not x or isInArray(x.use, item2.itemid) then return doPlayerSendCancel(cid, "Sorry, is not possible.") end if x.on or x.off then doSendMagicEffect(getThingPos(cid), 14) doRemoveItem(item.uid, 1) maxh = tonumber(getItemAttribute(item2.uid, "poke"):match("/(.+)]")) doItemSetAttribute(item2.uid, "poke", getItemAttribute(item2.uid, "poke"):sub(1, findLetter(getItemAttribute(item2.uid, "poke"), "[")) .. maxh .. getItemAttribute(item2.uid, "poke"):sub(findLetter(getItemAttribute(item2.uid, "poke"), "/"))) btype = getPokeballType(item2.itemid) ons = pokeballs[btype].on doTransformItem(item2.uid, ons) doCureAllStatus(item2.uid) setPlayerStorageValue(cid, storage_time, os.time() + (60 * minutes)) return true else doPlayerSendCancel(cid, "Sorry, is not possible.") return true end else doPlayerSendCancel(cid, "You need to wait " .. minutes .. " minutes to use this revive.") return doPlayerSendTextMessage(cid, message_color, "You need to wait " .. minutes .. " minutes to use this revive.") end end end
  2. Yan Oliveira

    Revive Com Tempo

    Sem spam, aguarde ser respondido. Quando for postar um código, poste ele inteiro, pois o que você colocou estava faltando parte (ou estava errado rsrs). Troque o código por esse: local level = 200 -- LEVEL MÍNIMO PARA USAR O REVIVE local storage_time = 68789 -- STORAGE PARA VERIFICAR O TEMPO PARA USAR O REVIVE local minutes = 10 -- MINUTOS PARA USAR O REVIVE local message_color = MESSAGE_STATUS_CONSOLE_BLUE -- COR DO TEXTO --------------- CÓDIGO --------------- function onUse(cid, item, frompos, item2, topos) if getPlayerLevel(cid) < level then doPlayerSendCancel(cid, "You need to be at least level " .. level .. " to use this revive.") return doPlayerSendTextMessage(cid, message_color, "You need to be at least level " .. level .. " to use this revive.") else if getPlayerStorageValue(cid, storage_time) <= os.time() then setPlayerStorageValue(cid, 8422, 0) setPlayerStorageValue(cid, 23254, 50) if isCreature(item2.uid) then return doPlayerSendCancel(cid, "You can only use revive in pokeballs!") end if isPlayer(item2.uid) then return doPlayerSendCancel(cid, "You cant use potions on wild pokemons.") end local x = pokeballs[getPokeballType(item2.itemid)] if not x or isInArray(x.use, item2.itemid) then return doPlayerSendCancel(cid, "Sorry, is not possible.") end if x.on or x.off then doSendMagicEffect(getThingPos(cid), 14) doRemoveItem(item.uid, 1) maxh = tonumber(getItemAttribute(item2.uid, "poke"):match("/(.+)]")) doItemSetAttribute(item2.uid, "poke", getItemAttribute(item2.uid, "poke"):sub(1, findLetter(getItemAttribute(item2.uid, "poke"), "[")) .. maxh .. getItemAttribute(item2.uid, "poke"):sub(findLetter(getItemAttribute(item2.uid, "poke"), "/"))) btype = getPokeballType(item2.itemid) ons = pokeballs[btype].on doTransformItem(item2.uid, ons) doCureAllStatus(item2.uid) setPlayerStorageValue(cid, storage_time, os.time() + (60 * minutes)) return true else doPlayerSendCancel(cid, "Sorry, is not possible.") return true end else return true end else doPlayerSendCancel(cid, "You need to wait " .. minutes .. " minutes to use this revive.") return doPlayerSendTextMessage(cid, message_color, "You need to wait " .. minutes .. " minutes to use this revive.") end end end
  3. De nada! Que bom que deu certo ?. ------------- EDIT ------------ @Sugismundo Eu editei o post que você marcou como melhor resposta, copia o código dele. Pois, do jeito que estava antes, se o player fosse usar a spell e não tivesse nenhum player disponível da party, ele ia considerar mesmo assim o cooldown de 5 minutos, mas agora arrumei para começar o cooldown assim que teleportar para o player.
  4. O problema está em uma verificação if que sua skill ou é menor que 0 (acho difícil) ou é maior que 6, então ele só seta o MagicLevel, mas estar resetando para level 10 eu não entendi. Tem que ver se não tem algum bloco no seu login.lua que está fazendo isso. Antes de colocar esse sistema estava normal?
  5. Sim, troque o código por esse: -- SCRIPT DE TELETRANSPORTE FEITO POR YAN18 -- local message_color = MESSAGE_STATUS_CONSOLE_BLUE -- COR DA MENSAGEM local effect = 36 -- EFEITO DO TELETRANSPORTE local mana = 150 -- TANTO DE MANA QUE VAI GASTAR PARA TELEPORTAR. SE QUISER SEM CUSTO, COLOQUE O VALOR 0 local storage_time = 55454 -- STORAGE PARA VERIFICAR SE PODE USAR A SPELL local minutes = 5 -- MINUTOS PARA USAR A SPELL NOVAMENTE -- FUNÇÃO LOCAL PARA TELETRANSPORTAR -- local function Teleportation(cid, index) if not cid then return true end if not isInParty(cid) then return doPlayerSendTextMessage(cid, message_color, "You need to be in a party to teleport. But if you are in a party, please report this problem.") end if index < 1 then return doPlayerSendTextMessage(cid, message_color, "There are not players available in your party for you teleport to him.") else local player = getPartyMembers(cid)[index] if getCreatureName(cid) ~= getCreatureName(player) then if string.lower(getCreatureName(player)) == string.lower(getCreatureName(player)) then if not getTileInfo(getThingPos(player)).house then doSendMagicEffect(getThingPos(cid), effect) doTeleportThing(cid, getThingPos(player)) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "TELEPORTATION!") doPlayerSendTextMessage(cid, message_color, "You had been teleportation to " .. getCreatureName(player) .. ".") setPlayerStorageValue(cid, storage_time, os.time() + (60 * minutes)) return true end end end addEvent(Teleportation, 10, cid, index - 1) end end --------------------- CÓDIGO --------------------- function onCastSpell(cid, var) if not cid then return true elseif not isInParty(cid) then return doPlayerSendTextMessage(cid, message_color, "You need to be in a party to teleport. But if you are in a party, please report this problem.") else if getPlayerStorageValue(cid, storage_time) <= os.time() then if getCreatureMana(cid) >= mana then Teleportation(cid, #getPartyMembers(cid)) return true else return doPlayerSendTextMessage(cid, message_color, "You need to have " .. mana .. " mana to use this ability.") end else return doPlayerSendTextMessage(cid, message_color, "You need to wait " .. minutes .. " minutes to use this ability again.") end end end
  6. Manda o link para mim dar uma olhada.
  7. Quando esse erro acontece? Ao puxar o pokémon quando está realizando a cura?
  8. Não entendi, como assim ficar sozinho não tem mensagem ao receber dano?
  9. Testa agora: local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) local storage_say = 78787 -- STORAGE PARA NÃO REPETIR A FALA local storage_life = 7777777 -- STORAGE QUE ARMAZENA LIFE PARA VERIFICAR SE SOFREU DANO local table_conditions = { CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_BLEEDING, CONDITION_HASTE, CONDITION_PARALYZE, CONDITION_INFIGHT, CONDITION_DRUNK, CONDITION_MUTED, CONDITION_FREEZING, CONDITION_DAZZLED, CONDITION_CURSED, CONDITION_HUNTING, } if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end for _, condition in pairs(table_conditions) do if getCreatureCondition(cid, condition) then return true end end setPlayerStorageValue(cid, storage_life, 0) if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end if (getPlayerStorageValue(cid, storage_life) > 0) and (getPlayerStorageValue(cid, storage_life) ~= getCreatureHealth(cid)) then return doSendAnimatedText(getThingPos(cid), "LOST HEAL", getThingPos(cid)) end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) setPlayerStorageValue(cid, storage_life, getCreatureHealth(cid)) if getPlayerStorageValue(cid, storage_say) < 1 then doSendAnimatedText(getThingPos(cid), "HEALING...", getThingPos(cid)) setPlayerStorageValue(cid, storage_say, 1) end addEvent(HealPerTurn, duration, cid, health, effect, time - 1, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {health = 1000, effect = 13}, -- full restore [12348] = {health = 3500, effect = 13}, -- hyper potion [12346] = {health = 5000, effect = 13}, -- ultra potion [12345] = {health = 8000, effect = 13}, -- super potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- 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 HealPerTurn(pokemon, potions[item.itemid].health, potions[item.itemid].effect, vezes_repete, segundos) doRemoveItem(item.uid, 1) return true end
  10. Eu acabei de editar o código ali em cima, tinha feito uma coisa errada. Copia e testa novamente.
  11. Sem spam amigo, aguarde ser respondido. Sobre o sistema de potion, eu imaginei que queria igual PXG pela print rs. Troque o código por esse: local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) local storage_say = 78787 -- STORAGE PARA NÃO REPETIR A FALA local storage_life = 7777777 -- STORAGE QUE ARMAZENA LIFE PARA VERIFICAR SE SOFREU DANO local table_conditions = { CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_BLEEDING, CONDITION_HASTE, CONDITION_PARALYZE, CONDITION_INFIGHT, CONDITION_DRUNK, CONDITION_MUTED, CONDITION_FREEZING, CONDITION_DAZZLED, CONDITION_CURSED, CONDITION_HUNTING, } if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end for _, condition in pairs(table_conditions) do if getCreatureCondition(cid, condition) then return true end end setPlayerStorageValue(cid, storage_life, 0) if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end if (getPlayerStorageValue(cid, storage_life) > 0) and (getPlayerStorageValue(cid, storage_life) ~= getCreatureHealth(cid)) then return doSendAnimatedText(cid, "LOST HEAL", getThingPos(cid)) end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) setPlayerStorageValue(cid, storage_life, getCreatureHealth(cid)) if getPlayerStorageValue(cid, storage_say) < 1 then doSendAnimatedText(cid, "HEALING...", getThingPos(cid)) setPlayerStorageValue(cid, storage_say, 1) end addEvent(HealPerTurn, duration, cid, health, effect, time - 1, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {health = 1000, effect = 13}, -- full restore [12348] = {health = 3500, effect = 13}, -- hyper potion [12346] = {health = 5000, effect = 13}, -- ultra potion [12345] = {health = 8000, effect = 13}, -- super potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- 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 HealPerTurn(pokemon, potions[item.itemid].health, potions[item.itemid].effect, vezes_repete, segundos) doRemoveItem(item.uid, 1) return true end Eu mudei as falas de doCreatureSay para doSendAnimatedText para ficar parecido com PXG. Testa e vê se da algum problema.
  12. Esse tutorial é aqui do fórum? Ele mexe na source?
  13. Se é uma quest e tem actionId, para que colocar o item dentro do baú? É melhor e mais fácil criar um script. Vai em Data/Actions/Scripts e crie um arquivo chamado reward_chest.lua e adicione o código: local id_item = 5478 -- ID DO ITEM QUE VAI RECEBER local quantidade = 1 -- QUANTIDADE DO ITEM QUE VAI RECEBER local id_bau = 7149 -- RECOMPENSA local effect = true -- COLOQUE true PARA TER EFEITO E false SEM EFEITO local id_effect = 28 -- ID DO EFEITO local storage = 32548 --- STORAGE PARA VERIFICAR SE JÁ FEZ A QUEST -------------- CÓDIGO -------------- function onUse(player, item, fromPos, itemEx, toPos) if item.itemid == id_bau then if not player or not item then return true else if player:getStorageValue(storage) < 1 then player:addAddItem(id_item, quantidade) if effect then player:getPosition():sendMagicEffect(id_effect) end player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations, you received " .. quantidade .. "x " .. getItemNameById(id_item) .. ".") player:setStorageValue(storage, 1) else return player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You already received your reward.") end end end end Agora abra o actions.xml e adicione a tag: <action actionid="XXXX" event="script" value="reward_chest.lua"/> <!-- ONDE ESTÁ XXXX COLQOUE A ActionId DO BAÚ --> Como comentado na tag, onde está XXXX coloque a ActionId e no código, eu deixei todas variáveis comentadas, está intuitivo, mas coloque o id do item que vai receber na varIável id_item e coloque o id do baú na variável id_bau, o actionid já está na tag xml. Teste e qualquer problema avisa, mas se quer o item visualmente no baú, vai ter que fazer código também... Então recomendo fazer dessa maneira que falei.
  14. Como assim domar as montarias?
  15. Eu tinha pensado que o seu ot era um Tibia rs, mas como é Dragon Ball Tibia, faz sentido até. Crie um arquivo na pasta Spells (se tiver uma subpasta de party adiciona dentro dela) chamado teleportation.lua e adiciona o código dentro: -- SCRIPT DE TELETRANSPORTE FEITO POR YAN18 -- local message_color = MESSAGE_STATUS_CONSOLE_BLUE -- COR DA MENSAGEM local effect = 36 -- EFEITO DO TELETRANSPORTE local mana = 150 -- TANTO DE MANA QUE VAI GASTAR PARA TELEPORTAR. SE QUISER SEM CUSTO, COLOQUE O VALOR 0 -- FUNÇÃO LOCAL PARA TELETRANSPORTAR -- local function Teleportation(cid, index) if not cid then return true end if not isInParty(cid) then return doPlayerSendTextMessage(cid, message_color, "You need to be in a party to teleport. But if you are in a party, please report this problem.") end if index < 1 then return doPlayerSendTextMessage(cid, message_color, "There are not players available in your party for you teleport to him.") else local player = getPartyMembers(cid)[index] if getCreatureName(cid) ~= getCreatureName(player) then if string.lower(getCreatureName(player)) == string.lower(getCreatureName(player)) then if not getTileInfo(getThingPos(player)).house then doSendMagicEffect(getThingPos(cid), effect) doTeleportThing(cid, getThingPos(player)) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "TELEPORTATION!") doPlayerSendTextMessage(cid, message_color, "You had been teleportation to " .. getCreatureName(player) .. ".") return true end end end addEvent(Teleportation, 10, cid, index - 1) end end --------------------- CÓDIGO --------------------- function onCastSpell(cid, var) if not cid then return true elseif not isInParty(cid) then return doPlayerSendTextMessage(cid, message_color, "You need to be in a party to teleport. But if you are in a party, please report this problem.") else if getCreatureMana(cid) >= mana then Teleportation(cid, #getPartyMembers(cid)) else return doPlayerSendTextMessage(cid, message_color, "You need to have " .. mana .. " mana to use this ability.") end end end Agora abra o arquivo spells.xml e adicione a tag: <instant name="Teletransporte" words="teleportation" lvl="1" mana="1" prem="0" aggressive="0" selftarget="1" exhaustion="0" needlearn="0" event="script" value="party/teleportation.lua"> <vocation id="1"/> <vocation id="2"/> <vocation id="3"/> <vocation id="4"/> <vocation id="5"/> </instant> Na tag xml da spell você configura certinho os atributos como custo de mana (eu deixei no próprio script um custo, se quiser deixar 0 no xml e configurar por lá, também dá!) se precisa de premium e as vocations que pode usar. E não esqueça de verificar o diretório. Eu testei aqui e funcionou! O teletransporte sempre vai para o último membro da lista de membros da party e se ele estiver dentro de uma house ele vai para o penúltimo e assim sucessivamente. O script vai fazer recursão até o primeiro membro da lista (tirando o próprio player que usa a spell) e se não encontrar nenhum disponível ele manda uma mensagem avisando. Não sei se tem a sprite do efeito de teletransporte no seu client, mas se não tiver, uma opção é nos poketibias, que tem uma sprite da passiva Evasion que tem um efeito similar ao teletransporte, é bem legal!
  16. Faltou o "=" para criar a tabela. Troque o código por esse: local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) local storage_say = 78787 -- STORAGE PARA NÃO REPETIR A FALA local table_conditions = { CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_BLEEDING, CONDITION_HASTE, CONDITION_PARALYZE, CONDITION_INFIGHT, CONDITION_DRUNK, CONDITION_MUTED, CONDITION_FREEZING, CONDITION_DAZZLED, CONDITION_CURSED, CONDITION_HUNTING, } if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end for _, condition in pairs(table_conditions) do if getCreatureCondition(cid, condition) then return true end end if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) if getPlayerStorageValue(cid, storage_say) < 1 then doCreatureSay(cid, "Healing") setPlayerStorageValue(cid, storage_say, 1) end addEvent(HealPerTurn, duration, cid, health, effect, time - 1, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {health = 1000, effect = 13}, -- full restore [12348] = {health = 3500, effect = 13}, -- hyper potion [12346] = {health = 5000, effect = 13}, -- ultra potion [12345] = {health = 8000, effect = 13}, -- super potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- 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 HealPerTurn(pokemon, potions[item.itemid].health, potions[item.itemid].effect, vezes_repete, segundos) doRemoveItem(item.uid, 1) return true end
  17. Eu adicionei uma verificação para caso o pokémon esteja em batalha ou com status negativo, e se estiver cancela a cura. local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) local storage_say = 78787 -- STORAGE PARA NÃO REPETIR A FALA local table_conditions { CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_BLEEDING, CONDITION_HASTE, CONDITION_PARALYZE, CONDITION_INFIGHT, CONDITION_DRUNK, CONDITION_MUTED, CONDITION_FREEZING, CONDITION_DAZZLED, CONDITION_CURSED, CONDITION_HUNTING, } if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end for _, condition in pairs(table_conditions) do if getCreatureCondition(cid, condition) then return true end end if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) if getPlayerStorageValue(cid, storage_say) < 1 then doCreatureSay(cid, "Healing") setPlayerStorageValue(cid, storage_say, 1) end addEvent(HealPerTurn, duration, cid, health, effect, time - 1, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {health = 1000, effect = 13}, -- full restore [12348] = {health = 3500, effect = 13}, -- hyper potion [12346] = {health = 5000, effect = 13}, -- ultra potion [12345] = {health = 8000, effect = 13}, -- super potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- 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 HealPerTurn(pokemon, potions[item.itemid].health, potions[item.itemid].effect, vezes_repete, segundos) doRemoveItem(item.uid, 1) return true end
  18. Que bom que deu certo! Coloque a solução como a melhor resposta para ajudar outros pessoas com o mesmo pedido. Vou olhar esse outro tópico.
  19. Então funcionou certinho né?
  20. 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.
  21. 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?
  22. 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
  23. Não entendi, você fica com a vida cheia ao usar a potion?
  24. É 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
  25. 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
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...