NB
pedido

Item Que Cura Por Porcentagem

Por nbb147, 23 de nov. de 2012 em Scripts

10
1.8k
nbb147N
23 de novembro de 2012 às 16:35

pessoal o ttulo ja diz tudo, eu quero um action de um item que cura por porcentagem..

GuhPkG
23 de novembro de 2012 às 17:22

Ta aqui um do PDA By Slicer!!!

 

 

 

 

function doHealOverTime(cid, div, turn, effect) --alterado v2.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 true

end

 

local d = div / 10000

local amount = math.floor(getCreatureMaxHealth(cid) * d)

doCreatureAddHealth(cid, amount)

if math.floor(turn/10) == turn/10 then

doSendMagicEffect(getThingPos(cid), effect)

end

addEvent(doHealOverTime, 100, cid, div, turn - 1, effect)

end

 

local potions = {

[12347] = {effect = 13, div = 30}, --super potion

[12348] = {effect = 13, div = 60}, --great potion

[12346] = {effect = 12, div = 80}, --ultra potion

[12345] = {effect = 14, div = 90}, --hyper potion

}

 

function onUse(cid, item, frompos, item2, topos)

local pid = getThingFromPosWithProtect(topos)

 

if not isCreature(pid) or not isSummon(pid) then

return doPlayerSendCancel(cid, "You can only use potions on 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, ""..getCreatureName(pid)..", take this potion!", TALKTYPE_SAY)

doSendMagicEffect(getThingPos(pid), 172)

setPlayerStorageValue(pid, 173, 1)

doRemoveItem(item.uid, 1)

 

local a = potions[item.itemid]

doHealOverTime(pid, a.div, 100, a.effect)

 

return true

end

 

 

 

Para configurar edita isso aqui:

 

 

local potions = {

[12347] = {effect = 13, div = 30}, --super potion

[12348] = {effect = 13, div = 60}, --great potion

[12346] = {effect = 12, div = 80}, --ultra potion

[12345] = {effect = 14, div = 90}, --hyper potion

}

 

Explicando o 1º, que ja serve para os demais...

 

[12347] = Id do item

effect = efeito

div = porcentagem que vai healar

Editado Novembro 23 por GuhPk

nbb147N
23 de novembro de 2012 às 18:03

é uma action? pq eu coloquei em action e deu esse erro:

 

 

 

[24/11/2012 17:59:05] data/actions/scripts/heal.lua:onUse

[24/11/2012 17:59:05] Description:

[24/11/2012 17:59:05] data/actions/scripts/heal.lua:23: attempt to call global 'getThingFromPosWithProtect' (a nil value)

[24/11/2012 17:59:05] stack traceback:

[24/11/2012 17:59:05] data/actions/scripts/heal.lua:23: in function <data/actions/scripts/heal.lua:22>

GuhPkG
23 de novembro de 2012 às 18:40

Aqui está em action e está funcionando perfeitamente!! '-'

TAG:

 

<action itemid="12343;12345-12348" event="script" value="potion.lua" allowfaruse="1" blockwalls="1"/>

 

action itemid=" id dos items "

value = " nome do arquivo.lua "

nbb147N
23 de novembro de 2012 às 19:01
:/ o erro continua
LuckOakeL
23 de novembro de 2012 às 19:30

Tó:

 

 

function onUse(cid, item, itemEx)
local percent = 10 -- Porcentagem de cura
local type = "ambos" -- Tipo de cura (health / mana / ambos)
local exha = 1 -- Tempo de exhaustion em segundos

if exhaustion.check(cid, 7322) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED) return true
elseif itemEx.uid ~= cid then
doPlayerSendCancel(cid, "You may only use this potion on yourself.") return true
end
if type == "health" then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(percent/100))
elseif type == "mana" then
doPlayerAddMana(cid, getPlayerMaxMana(cid)*(percent/100))
elseif type == "ambos" then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(percent/100))
doPlayerAddMana(cid, getPlayerMaxMana(cid)*(percent/100))
end
exhaustion.set(cid, 7322, exha)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER)
doRemoveItem(item.uid, 1)
return true
end

 

 

Configurando:

 

local percent = 10 -- Porcentagem de cura
local type = "ambos" -- Tipo de cura (health / mana / ambos)
local exha = 1 -- Tempo de exhaustion em segundos

Editado Novembro 23 por LuckOake

nbb147N
23 de novembro de 2012 às 19:38

quando uso nao cura nao faz nada so aparece, "You may only use this potion on yourself.", e nao da nenhum erro..

LuckOakeL
23 de novembro de 2012 às 19:44

Opa, cometi um errinho.

 

 

function onUse(cid, item, itemEx)
local percent = 10 -- Porcentagem de cura
local type = "ambos" -- Tipo de cura (health / mana / ambos)
local exha = 1 -- Tempo de exhaustion em segundos

if exhaustion.check(cid, 7322) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED) return true
elseif itemEx.uid == cid then
doPlayerSendCancel(cid, "You may only use this potion on yourself.") return true
end
if type == "health" then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(percent/100))
elseif type == "mana" then
doPlayerAddMana(cid, getPlayerMaxMana(cid)*(percent/100))
elseif type == "ambos" then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(percent/100))
doPlayerAddMana(cid, getPlayerMaxMana(cid)*(percent/100))
end
exhaustion.set(cid, 7322, exha)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER)
doRemoveItem(item.uid, 1)
return true
end

 

nbb147N
23 de novembro de 2012 às 20:43

funcionou perfeitamente ^^

ty rep+

SkyLighS
23 de novembro de 2012 às 20:45

duvida sanada

reportado

 

Para um superior