Ir para conteúdo

Yan Oliveira

Moderador
  • Total de itens

    2187
  • Registro em

  • Última visita

  • Dias Ganhos

    57

Tudo que Yan Oliveira postou

  1. Eu acabei de editar o código ali em cima, tinha feito uma coisa errada. Copia e testa novamente.
  2. 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.
  3. Esse tutorial é aqui do fórum? Ele mexe na source?
  4. 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.
  5. Estranho, de onde baixou essa base? Eu tenho uma base TFS 1.2 e tem o actions.xml e movements.xml nos seus respectivos diretórios normal.
  6. Como assim domar as montarias?
  7. 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!
  8. 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
  9. 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
  10. 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.
  11. 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.
  12. 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?
  13. 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
  14. Não entendi, você fica com a vida cheia ao usar a potion?
  15. É 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
  16. 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
  17. 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.
  18. Tem algum motivo plausível para você querer como uma spell? Por que não pode ser por talkaction?
  19. Sobre a fala se repetir apenas uma vez, sem problemas! 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 if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true 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 Sobre esse outro script que você quer, vai ter que criar um tópico novo para isso. Cria que eu te ajudo.
  20. Deixei a fala apenas por enfeite, mas é bem simples, 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) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true 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) 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
  21. Você precisa explicar melhor, pois quando falou que está usando infinito, eu entendi que a cura estava sendo infinita, e não o uso. E sim, realmente esqueci de remover o item. Sobre esse erro, nos testes que fiz aqui não deu. Você está usando em summon ou player? Arrumei e agora está removendo o item: 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) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true 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) doCreatureSay(cid, "Healing...") 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
  22. Sim, eu entendi o que você quer. É estranho, pois eu testei aqui e está funcionando normal. 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) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true 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) doCreatureSay(cid, "Healing...") 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) return true end Já está configurado para curar o tanto de health que tem em cada potion na tabela das potions por 10 segundos.
  23. Sobre erro, é porque eu escrevi errado o nome da função, digitei uma letra errada, troque o código por esse: local function HealPerTurn(cid, health, effect, seconds, time) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true 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) doCreatureSay(cid, "Healing...") addEvent(HealPerTurn, duration, cid, health, effect, seconds, time - 1) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12343] = {health = 1000, effect = 14}, -- full restore [12345] = {health = 3500, effect = 14}, -- hyper potion [12346] = {health = 5000, effect = 12}, -- ultra potion [12347] = {health = 8000, effect = 13}, -- super potion [12348] = {health = 10000, effect = 13}, -- great 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) return true end E sobre só curar uma vez, foi erro meu, eu havia esquecido de fazer recursão.
  24. Esqueci de colocar o campo health da tabela das potions no parâmetro health da função. 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) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true 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) doCreatureSau(cid, "Healing...") addEvent(HealPerTurn, duration, cid, health, effect, time, 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 = { [12343] = {health = 1000, effect = 14}, -- full restore [12345] = {health = 3500, effect = 14}, -- hyper potion [12346] = {health = 5000, effect = 12}, -- ultra potion [12347] = {health = 8000, effect = 13}, -- super potion [12348] = {health = 10000, effect = 13}, -- great 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) return true end
  • Quem Está Navegando   0 membros estão online

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