Em 22/03/2021 em 18:57, KaboFlow disse:Versão do Servidor: TFS - 1.0Tipo de Script: actionsCódigo:function doHealOverTime(cid, hp, effect) if not isCreature(cid) then return true end doSendMagicEffect(getThingPos(cid), effect) doCreatureAddHealth(cid, math.floor(hp)) end local potions = { [12347] = {effect = 14, hp = 120}, --super potion [12348] = {effect = 14, hp = 300}, --great potion [12346] = {effect = 14, hp = 800}, --ultra potion [12345] = {effect = 14, hp = 2000}, --hyper potion [7588] = {effect = 14, hp = 6000}, -- full restore } function onUse(cid, item, frompos, item2, topos) local pid = getThingFromPosWithProtect(topos) if not isSummon(pid) or getCreatureMaster(pid) ~= cid then return doPlayerSendCancel(cid, "You can only use potions on your own Pokemons!") end if getCreatureHealth(pid) == getCreatureMaxHealth(pid) then return doPlayerSendCancel(cid, "This pokemon is already at full health.") end if getPlayerStorageValue(pid, 173) >= 1 then setPlayerStorageValue(pid, 173, -1) end if getPlayerStorageValue(cid, 52481) >= 1 then return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendCancel(cid, "You can't use potion during gym battles.") return true end doCreatureSay(cid, "".. getCreatureName(pid)..", take this potion!", TALKTYPE_MONSTER) doSendMagicEffect(getThingPos(pid), 0) setPlayerStorageValue(pid, 173, 1) doRemoveItem(item.uid, 1) local a = potions[item.itemid] doHealOverTime(pid, a.hp, a.effect) doPlayerSendCancel(cid, "Your monsters recovered " ..a.hp.. " of HP.") return true endEu quero uma poção que cura uma porcentagem de exemplo
que cura o pokémon de 10.000, mas que cura por segundo de 1000. até atingir 10.000
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], potions[item.itemid].effect, vezes_repete, segundos) return true end
Substitua o código por esse e mude os id das potions na tabela e as respectivas vida e efeito de cada potion. Deixei todas as variáveis comentadas, só mudar os valores na tabela de potions que está tudo pronto.




info
Grupo: Visconde
Registrado: 04/07/17
Posts: 434
Reputação: +54
Eu quero uma poção que cura uma porcentagem de exemplo
que cura o pokémon de 10.000, mas que cura por segundo de 1000. até atingir 10.000