NA
pedido

Item de Regen

Por narutomaniacos, 16 de mai. de 2015 em Scripts

8.54
item
script
resolvido
5
1.3k
narutomaniacosN
16 de maio de 2015 às 14:51

Bom Galera eu queria primeiro saber se é possível,e se for possível pedir um item que regenera HP e MANA mais não tão simples assim,um item que regenera HP e MANA baseado no MAX HP e MANA do player

 

Exemplo: ao usar tal item o player regenera 25% da vida total dele

 

Script atual(regenera totalmente a vida do player)

function onUse(cid, item, fromPosition, itemEx, toPosition)

ITEM = 2673
local storage = 50000
local wait = 0.7
if fromPosition.x ~= CONTAINER_POSITION and exhaustion.get(cid, storage) == FALSE then
REG_HEALTH = getCreatureMaxHealth(cid)
REG_MANA = getPlayerMaxMana(cid)
doPlayerAddMana(cid, REG_MANA)
doCreatureAddHealth(cid, REG_HEALTH)
doCreatureSay(cid, 'Power is back !', TALKTYPE_ORANGE_1)
doRemoveItem(item.uid, 1)
exhaustion.set(cid, storage, wait)
elseif item.itemid == ITEM and exhaustion.get(cid, storage) == FALSE then
REG_HEALTH = getCreatureMaxHealth(cid)
REG_MANA = getPlayerMaxMana(cid)
doPlayerAddMana(cid, REG_MANA)
doCreatureAddHealth(cid, REG_HEALTH)
doCreatureSay(cid, 'Power is back !', TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
exhaustion.set(cid, storage, wait)
else
doPlayerSendCancel(cid, "You are exhausted.")
end
return TRUE
end

gabrielbsalesG
16 de maio de 2015 às 15:53
Melhor resposta

Uma edição do seu script:

local HP_PERCENT = 25 --%
local M_PERCENT = 25
function onUse(cid, item, fromPosition, itemEx, toPosition)
	ITEM = 2673
	local storage = 50000
	local wait = 0.7
	if fromPosition.x ~= CONTAINER_POSITION and exhaustion.get(cid, storage) == FALSE then
		REG_HEALTH = math.floor(getCreatureMaxHealth(cid) * (HP_PERCENT/100))
		REG_MANA = math.floor(getPlayerMaxMana(cid) * (M_PERCENT/100))
		doPlayerAddMana(cid, REG_MANA)
		doCreatureAddHealth(cid, REG_HEALTH)
		doCreatureSay(cid, 'Power is back !', TALKTYPE_ORANGE_1)
		doRemoveItem(item.uid, 1)
		exhaustion.set(cid, storage, wait)
	elseif item.itemid == ITEM and exhaustion.get(cid, storage) == FALSE then
		REG_HEALTH = math.floor(getCreatureMaxHealth(cid) * (HP_PERCENT/100))
		REG_MANA = math.floor(getPlayerMaxMana(cid) * (M_PERCENT/100))
		doPlayerAddMana(cid, REG_MANA)
		doCreatureAddHealth(cid, REG_HEALTH)
		doCreatureSay(cid, 'Power is back !', TALKTYPE_ORANGE_1)
		doRemoveItem(item.uid,1)
		exhaustion.set(cid, storage, wait)
	else
		doPlayerSendCancel(cid, "You are exhausted.")
	end
	return TRUE
end

Edite as variáveis HP_PERCENT e M_PERCENT.

O math.floor é pra não ficar valores "quebrados".

Editado Maio 16 por Featzen

narutomaniacosN
16 de maio de 2015 às 16:39

Muito obrigado,Devidamente testado e 100% funcional. REP+

gabrielbsalesG
16 de maio de 2015 às 16:47

De nada. Agora, marque como melhor resposta, para que o post seja dado como resolvido.

FurabioF
16 de maio de 2015 às 17:01

Tópico movido para a seção de dúvidas e pedidos resolvidos.