Ir para conteúdo
  • 0

Potion


M i s s

Pergunta

Oi, alguém pode me ajudar com isso?

Eu gostaria que não fosse possivel o player usar as potions/revive em area PZ.

 

Script das potions:

 

Spoiler

function doHealOverTime(cid, div, turn, effect)
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
if useOTClient then
   onPokeHealthChange(getCreatureMaster(cid)) --alterei aki
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

 

Script revive, aqui eu gostaria que nao resetasse o cooldawn também se possivel :c

Spoiler

local storage = 121212 --storage da quest

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

if getPlayerStorageValue(cid, storage) == 0 then
   doPlayerSendCancel(cid, "You already have used the limit of revives for this quest.")
   return true
elseif getPlayerStorageValue(cid, 990) >= 1 then
   doPlayerSendCancel(cid, "You can't use revive during gym battles.")
   return true
elseif getPlayerStorageValue(cid, 52481) >= 1 then
   doPlayerSendCancel(cid, "You can't do that while a duel.") --alterado v1.6
   return true
elseif isPlayer(item2.uid) then
   doPlayerSendCancel(cid, "Please, use revive only on pokeballs.")
   return true
end

for a, b in pairs (pokeballs) do
    if not item2.itemid == b.on or not item2.itemid == b.off then
           doPlayerSendCancel(cid, "Please, use revive only on pokeballs.")
           return true
    end
end

local pokeball = getPlayerSlotItem(cid, 8)
for a, b in pairs (pokeballs) do
    if item2.itemid == b.on or item2.itemid == b.off then
           doTransformItem(item2.uid, b.on)
           doSetItemAttribute(item2.uid, "hp", 1)
           for c = 1, 15 do
                   local str = "move"..c
                   setCD(item2.uid, str, 0)
           end
           setCD(item2.uid, "control", 0)
           setCD(item2.uid, "blink", 0) --alterado v1.6
           doSendMagicEffect(getThingPos(cid), 13)
           doRemoveItem(item.uid, 1)
           doCureBallStatus(getPlayerSlotItem(cid, 8).uid, "all")
           doCureStatus(cid, "all", true)
           cleanBuffs2(item2.uid) --alterado v1.5
           if useOTClient then
              onPokeHealthChange(cid)
           end
           if getPlayerStorageValue(cid, storage) > 0 then
                  setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage)-1)
           end
           return true
    end
end
return true
end

 

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 1

@R e d Tenta esse e me fala se funcionou das potions:
 



function doHealOverTime(cid, div, turn, effect)
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
if useOTClient then
   onPokeHealthChange(getCreatureMaster(cid)) --alterei aki
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 (getTileInfo(fromPosition).protection == TRUE) then
	return true
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

 

Link para o comentário
Compartilhar em outros sites

  • 0

Nao foi possivel usar nenhuma das potion em qlqr lugar sendo PZ ou nao

 

[26/12/2019 19:05:40] [Error - Action Interface] 
[26/12/2019 19:05:40] data/actions/scripts/potion.lua:onUse
[26/12/2019 19:05:40] Description: 
[26/12/2019 19:05:40] attempt to index a nil value
[26/12/2019 19:05:40] stack traceback:
[26/12/2019 19:05:41]     [C]: in function 'getTileInfo'
[26/12/2019 19:05:41]     data/actions/scripts/potion.lua:35: in function <data/actions/scripts/potion.lua:28>

Editado por R e d
Link para o comentário
Compartilhar em outros sites

  • Quem Está Navegando   0 membros estão online

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