Ir para conteúdo

Featured Replies

Postado
function doHealOverTime(cid, heal, turn, effect)       
	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) + 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 ?

Doar

  • Respostas 10
  • Visualizações 856
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • 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)/

  • Editado o copia de cima, testa agora

Postado
  • Autor

Deu um probleminha

[06/02/2018 18:40:18] [Error - Action Interface] 
[06/02/2018 18:40:18] data/actions/scripts/potion.lua:onUse
[06/02/2018 18:40:18] Description: 
[06/02/2018 18:40:18] attempt to index a function value
[06/02/2018 18:40:18] stack traceback:
[06/02/2018 18:40:18] 	[C]: in function 'doSendAnimatedText'
[06/02/2018 18:40:18] 	data/actions/scripts/potion.lua:16: in function 'doHealOverTime'
[06/02/2018 18:40:18] 	data/actions/scripts/potion.lua:60: in function <data/actions/scripts/potion.lua:31>

 

Postado
  • Solução
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
	   return setPlayerStorageValue(cid, 173, -1)
	elseif getCreatureHealth(cid) + regen >= getCreatureMaxHealth(cid) then
	   doSendAnimatedText(getThingPos(cid), "+".. regen .."%", 65)
	   doCreatureAddHealth(cid, regen)
	   doSendMagicEffect(getThingPos(cid), effect)
	   return setPlayerStorageValue(cid, 173, -1)
	end


	doSendAnimatedText(getThingPos(cid), "+ "..heal.."%", 65)
	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 por DboExplorer (veja o histórico de edições)

 

Te ajudei ?? Que tal fazer uma contribuição ?

Doar

Postado
  • Autor

Ainda 

 

[06/02/2018 18:53:22] [Error - Action Interface] 
[06/02/2018 18:53:22] data/actions/scripts/potion.lua:onUse
[06/02/2018 18:53:22] Description: 
[06/02/2018 18:53:22] attempt to index a function value
[06/02/2018 18:53:22] stack traceback:
[06/02/2018 18:53:22] 	[C]: in function 'doSendAnimatedText'
[06/02/2018 18:53:22] 	data/actions/scripts/potion.lua:15: in function 'doHealOverTime'
[06/02/2018 18:53:22] 	data/actions/scripts/potion.lua:59: in function <data/actions/scripts/potion.lua:30>

 

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo