KA

Potion de Pokemon que cura metade da vida do pokémon

Por KaboFlow, 03 de abr. de 2021 em Scripts

poketibia
pda
tibia
19
5.1k
KaboFlowK
03 de abril de 2021 às 00:53

que cura metade da vida do pokémon

 

uma poção que cura em%

exemplo

usar a poção cura você em 50% da vida do pokémon

Yan OliveiraY
03 de abril de 2021 às 01:07
13 minutos atrás, KaboFlow disse:
Versão do Servidor: TFS - 0.3.4
Tipo de Script: actions
Código:
  Mostrar conteúdo oculto



 

que cura metade da vida do pokémon

 

uma poção que cura em%

exemplo

usar a poção cura você em 50% da vida do pokémon

 

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.

Editado Abril 3 por Yan18

KaboFlowK
03 de abril de 2021 às 01:14
5 minutos atrás, Yan18 disse:

 

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.

 

 


[02/04/2021 22:13:35] [Error - Action Interface] 
[02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:onUse
[02/04/2021 22:13:35] Description: 
[02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:14: attempt to compare number with nil
[02/04/2021 22:13:35] stack traceback:
[02/04/2021 22:13:35]     data/actions/scripts/potion/potion.lua:14: in function 'HealHealthPercent'
[02/04/2021 22:13:35]     data/actions/scripts/potion/potion.lua:54: in function <data/actions/scripts/potion/potion.lua:31>

 

 

não cura nada

Yan OliveiraY
03 de abril de 2021 às 01:16
2 minutos atrás, KaboFlow disse:

 

 


[02/04/2021 22:13:35] [Error - Action Interface] 
[02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:onUse
[02/04/2021 22:13:35] Description: 
[02/04/2021 22:13:35] data/actions/scripts/potion/potion.lua:14: attempt to compare number with nil
[02/04/2021 22:13:35] stack traceback:
[02/04/2021 22:13:35]     data/actions/scripts/potion/potion.lua:14: in function 'HealHealthPercent'
[02/04/2021 22:13:35]     data/actions/scripts/potion/potion.lua:54: in function <data/actions/scripts/potion/potion.lua:31>

 

 

não cura nada

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

 

Editado Abril 3 por Yan18

KaboFlowK
03 de abril de 2021 às 01:22
5 minutos atrás, Yan18 disse:

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

 

 

 


[02/04/2021 22:22:34] [Error - Action Interface] 
[02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:onUse
[02/04/2021 22:22:34] Description: 
[02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:14: attempt to compare number with nil
[02/04/2021 22:22:34] stack traceback:
[02/04/2021 22:22:34]     data/actions/scripts/potion/potion.lua:14: in function 'HealHealthPercent'
[02/04/2021 22:22:34]     data/actions/scripts/potion/potion.lua:54: in function <data/actions/scripts/potion/potion.lua:31>

 

mismo error

Yan OliveiraY
03 de abril de 2021 às 01:24
Agora, KaboFlow disse:

 

 


[02/04/2021 22:22:34] [Error - Action Interface] 
[02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:onUse
[02/04/2021 22:22:34] Description: 
[02/04/2021 22:22:34] data/actions/scripts/potion/potion.lua:14: attempt to compare number with nil
[02/04/2021 22:22:34] stack traceback:
[02/04/2021 22:22:34]     data/actions/scripts/potion/potion.lua:14: in function 'HealHealthPercent'
[02/04/2021 22:22:34]     data/actions/scripts/potion/potion.lua:54: in function <data/actions/scripts/potion/potion.lua:31>

 

mismo error

 

É 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

 

KaboFlowK
03 de abril de 2021 às 01:27
2 minutos atrás, Yan18 disse:

 

É 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

 

 


[02/04/2021 22:26:37] [Error - Action Interface] 
[02/04/2021 22:26:37] data/actions/scripts/potion/potion.lua:onUse
[02/04/2021 22:26:37] Description: 
[02/04/2021 22:26:37] (luaDoPlayerSendCancel) Player not found

 

 

 

Eu fico agora se você puxar

esse erro ocorre quando o Pokémon está cheio de vida

Não sei porque mas já fico ...

Yan OliveiraY
03 de abril de 2021 às 01:29
Agora, KaboFlow disse:

 


[02/04/2021 22:26:37] [Error - Action Interface] 
[02/04/2021 22:26:37] data/actions/scripts/potion/potion.lua:onUse
[02/04/2021 22:26:37] Description: 
[02/04/2021 22:26:37] (luaDoPlayerSendCancel) Player not found

 

 

 

Eu fico agora se você puxar

esse erro ocorre quando o Pokémon está cheio de vida

Não sei porque mas já fico ...

 

Não entendi, você fica com a vida cheia ao usar a potion?

KaboFlowK
03 de abril de 2021 às 01:32
3 minutos atrás, Yan18 disse:

 

Não entendi, você fica com a vida cheia ao usar a potion?

 

nada nada que se funcionar eu fico

o que acontece se o pokémon estiver 100%

e tento usar a poção dá aquele erro

Antes que eu esqueça, eu poderia ter esfriado?

Ao usar a poção, você tem que esperar 3 minutos para usá-la novamente?

Yan OliveiraY
03 de abril de 2021 às 01:36
1 minuto atrás, KaboFlow disse:

 

nada nada que se funcionar eu fico

o que acontece se o pokémon estiver 100%

e tento usar a poção dá aquele erro

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

 

KaboFlowK
03 de abril de 2021 às 01:37
1 minuto atrás, Yan18 disse:

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

 

 

Antes que eu esqueça, eu poderia ter esfriado?

Ao usar a poção, você tem que esperar 3 minutos para usá-la novamente?

perfect

funciona.png.d75e927dcb5b3438606141e9a6716b86.png

Yan OliveiraY
03 de abril de 2021 às 01:38
1 minuto atrás, KaboFlow disse:

 

Antes que eu esqueça, eu poderia ter esfriado?

Ao usar a poção, você tem que esperar 3 minutos para usá-la novamente?

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?

Editado Abril 3 por Yan18

KaboFlowK
03 de abril de 2021 às 01:41
2 minutos atrás, Yan18 disse:

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?

 

sim

com tempo em 3min

Yan OliveiraY
03 de abril de 2021 às 01:47
Melhor resposta
4 minutos atrás, KaboFlow disse:

 

sim

com tempo em 3min

 

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.

KaboFlowK
03 de abril de 2021 às 01:50
2 minutos atrás, Yan18 disse:

 

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.

 

 

22:50 You need to wait 3 minutes to use the potion again.

 

 

obrigado este tópico fica

Eu gostaria que você checasse o outro.

Estou aqui obrigado

eles podem fechar o tópico