Postado Fevereiro 6, 2018 7 anos Gostaria de colocar as potions de usar nos pokemons para curar em porcentagem, ao longo de 10 segundos. function doHealOverTime(cid, heal, turn, effect) --alterado v1.6 peguem o script todo!! if not isCreature(cid) then return true end if turn <= 0 or (getCreatureHealth(cid) == getCreatureMaxHealth(cid)) or getPlayerStorageValue(cid, 173) <= 0 then setPlayerStorageValue(cid, 173, -1) return elseif getCreatureHealth(cid) + heal/10 >= getCreatureMaxHealth(cid) then doSendAnimatedText(getThingPos(cid), "+"..getCreatureMaxHealth(cid) - getCreatureHealth(cid), 65) doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid)) doSendMagicEffect(getThingPos(cid), 12) return end doSendAnimatedText(getThingPos(cid), "+"..heal/10, 65) doCreatureAddHealth(cid, heal/10) doSendMagicEffect(getThingPos(cid), 12) addEvent(doHealOverTime, 1000, cid, heal, turn - 1, effect) addEvent(doUpdateStatusPoke, 1100, getCreatureMaster(cid)) end local potions = { [2273] = {health = 400, animate = "SMALL POT", collor = 140}, [2272] = {health = 1500, animate = "GREAT POT", collor = 140}, [2271] = {health = 4000, animate = "MEGA POT", collor = 140}, [2275] = {health = 10000, animate = "HYPER POT", collor = 140}, [2274] = {health = 30000, animate = "SUPER POT", collor = 140}, } function onUse(cid, item, frompos, item2, topos) local pid = getThingFromPosWithProtect(topos) local pokeballInfo = getPokeballInfo(getPlayerSlotItem(cid, 8).uid) if not isCreature(pid) or not isSummon(pid) then return doPlayerSendCancel(cid, "You can only use potions on your own Pokemons!") end if 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 return doPlayerSendCancel(cid, "This pokemon is already under effects of potions.") end if getPlayerStorageValue(cid, 52481) >= 1 then return doPlayerSendCancel(cid, "You can't do that while a duel.") end doCreatureSay(cid, "".. pokeballInfo.nick..", take this potion!", TALKTYPE_SAY) doSendAnimatedText(getThingPos(pid), potions[item.itemid].animate, potions[item.itemid].collor) setPlayerStorageValue(pid, 173, 1) doRemoveItem(item.uid, 1) doHealOverTime(pid, potions[item.itemid].health, 10, 12) return true end
Postado Fevereiro 6, 2018 7 anos function doHealOverTime(cid, heal, turn, effect) --alterado v1.6 peguem o script todo!! if not isCreature(cid) then return true end local regen = (heal*getCreatureMaxHealth(cid)/100) if turn <= 0 or (getCreatureHealth(cid) == getCreatureMaxHealth(cid)) or getPlayerStorageValue(cid, 173) <= 0 then setPlayerStorageValue(cid, 173, -1) return elseif (getCreatureHealth*getCreatureMaxHealth(cid)/100) + regen >= getCreatureMaxHealth(cid) then doSendAnimatedText(getThingPos(cid), "+".. math.ceil(100 - getCreatureHealth/getCreatureMaxHealth*100) .."%", 65) doCreatureAddHealth(cid, regen) doSendMagicEffect(getThingPos(cid), effect) return end doSendAnimatedText(getThingPos(cid), "+ "..heal.."%") doCreatureAddHealth(cid, regen ) doSendMagicEffect(getThingPos(cid), effect) addEvent(doHealOverTime, 1000, cid, heal, turn - 1, effect) addEvent(doUpdateStatusPoke, 1005, getCreatureMaster(cid)) end local potions = { [2273] = {health = 5, duration=10,effect= 12, animate = "SMALL POT", collor = 140}, [2272] = {health = 10, duration=10,effect= 12, animate = "GREAT POT", collor = 140}, [2271] = {health = 25, duration=10,effect= 12, animate = "MEGA POT", collor = 140}, [2275] = {health = 40,duration=10, effect= 12, animate = "HYPER POT", collor = 140}, [2274] = {health = 60, duration=10,effect= 12, animate = "SUPER POT", collor = 140}, } function onUse(cid, item, frompos, item2, topos) local pid = getThingFromPosWithProtect(topos) local pokeballInfo = getPokeballInfo(getPlayerSlotItem(cid, 8).uid) if not isCreature(pid) or not isSummon(pid) then return doPlayerSendCancel(cid, "You can only use potions on your own Pokemons!") end if 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 return doPlayerSendCancel(cid, "This pokemon is already under effects of potions.") end if getPlayerStorageValue(cid, 52481) >= 1 then return doPlayerSendCancel(cid, "You can't do that while a duel.") end doCreatureSay(cid, "".. pokeballInfo.nick..", take this potion!", TALKTYPE_SAY) doSendAnimatedText(getThingPos(pid), potions[item.itemid].animate, potions[item.itemid].collor) setPlayerStorageValue(pid, 173, 1) doRemoveItem(item.uid, 1) doHealOverTime(pid, potions[item.itemid].health, potions[item.itemid].duration, potions[item.itemid].effect) return true end Editado Fevereiro 6, 2018 7 anos por DboExplorer (veja o histórico de edições) Te ajudei ?? Que tal fazer uma contribuição ?
Postado Fevereiro 6, 2018 7 anos Autor Deu errado amigão, acusou erro [06/02/2018 18:20:29] [Error - LuaScriptInterface::loadFile] data/actions/scripts/potion.lua:9: unexpected symbol near '*' [06/02/2018 18:20:29] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/potion.lua) [06/02/2018 18:20:29] data/actions/scripts/potion.lua:9: unexpected symbol near '*'
Postado Fevereiro 6, 2018 7 anos function doHealOverTime(cid, heal, turn, effect) --alterado v1.6 peguem o script todo!! if not isCreature(cid) then return true end local regen = (heal*getCreatureMaxHealth(cid)/100) if turn <= 0 or (getCreatureHealth(cid) == getCreatureMaxHealth(cid)) or getPlayerStorageValue(cid, 173) <= 0 then setPlayerStorageValue(cid, 173, -1) return elseif (getCreatureHealth(cid)*getCreatureMaxHealth(cid)/100) + regen >= getCreatureMaxHealth(cid) then doSendAnimatedText(getThingPos(cid), "+".. math.ceil(100 - getCreatureHealth(cid)/getCreatureMaxHealth(cid)*100) .."%", 65) doCreatureAddHealth(cid, regen) doSendMagicEffect(getThingPos(cid), effect) return end doSendAnimatedText(getThingPos(cid), "+ "..heal.."%") doCreatureAddHealth(cid, regen ) doSendMagicEffect(getThingPos(cid), effect) addEvent(doHealOverTime, 1000, cid, heal, turn - 1, effect) addEvent(doUpdateStatusPoke, 1005, getCreatureMaster(cid)) end local potions = { [2273] = {health = 5, duration=10,effect= 12, animate = "SMALL POT", collor = 140}, [2272] = {health = 10, duration=10,effect= 12, animate = "GREAT POT", collor = 140}, [2271] = {health = 25, duration=10,effect= 12, animate = "MEGA POT", collor = 140}, [2275] = {health = 40,duration=10, effect= 12, animate = "HYPER POT", collor = 140}, [2274] = {health = 60, duration=10,effect= 12, animate = "SUPER POT", collor = 140}, } function onUse(cid, item, frompos, item2, topos) local pid = getThingFromPosWithProtect(topos) local pokeballInfo = getPokeballInfo(getPlayerSlotItem(cid, 8).uid) if not isCreature(pid) or not isSummon(pid) then return doPlayerSendCancel(cid, "You can only use potions on your own Pokemons!") end if 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 return doPlayerSendCancel(cid, "This pokemon is already under effects of potions.") end if getPlayerStorageValue(cid, 52481) >= 1 then return doPlayerSendCancel(cid, "You can't do that while a duel.") end doCreatureSay(cid, "".. pokeballInfo.nick..", take this potion!", TALKTYPE_SAY) doSendAnimatedText(getThingPos(pid), potions[item.itemid].animate, potions[item.itemid].collor) setPlayerStorageValue(pid, 173, 1) doRemoveItem(item.uid, 1) doHealOverTime(pid, potions[item.itemid].health, potions[item.itemid].duration, potions[item.itemid].effect) return true end Te ajudei ?? Que tal fazer uma contribuição ?
Postado Fevereiro 6, 2018 7 anos Autor Funcionando! mas quando eu uso uma potion ela n dura os 10 segundos e fica dizendo "This pokemon is aready under effects of potions.". Se achar mais fácil, pode tirar os 10 segundos e colocar para ela healar de uma só vez
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.