• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Action] Regeneration Request

F

Forsakenfate

Guest
I'd like to request a script that when you right-click on an item, your HP regenerates for about 5 seconds.
With a cooldown of 5 seconds and it must heal an amount of HP every second, doesn't matter how much I'll edit that later.
Like you click on it, the item dissapears/loses 1 of his stack, and it heals 20 HP every second for 5 seconds.
If anyone could help me with this I'd be more then happy.
I'm using TFS 0.3.6.
Rep for help.
 
Something like this?

PHP:
local config = {
	amount = 20, -- HPs by second
	time = 10 -- seconds
}

local function doRegeneration(cid, amount, seconds)
	if seconds <= 0 then
		return FALSE
	end
	doCreatureAddHealth(cid, amount)
	doSendAnimatedText(getThingPos(cid), "+" .. amount, COLOR_LIGHTBLUE)
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
	return addEvent(doRegeneration, 1000, cid, amount, seconds - 1)
end
		
function onUse(cid, item, fromPosition, itemEx, toPosition)
	doRemoveItem(item.uid, 1)
	doRegeneration(cid, config.amount, config.time)
	return TRUE
end
 
Try.
PHP:
local config = {
	amount = 20, -- HPs by second
	time = 5, -- seconds
	exhaust = {
		storage = 1000,
		time = 10, -- Exhaust time seconds~
	}
}

local function doRegeneration(cid, amount, seconds)
	if seconds <= 0 then
		return false
	end
	doCreatureAddHealth(cid, amount)
	doSendAnimatedText(getThingPos(cid), "+" .. amount, COLOR_LIGHTBLUE)
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
	return addEvent(doRegeneration, 1000, cid, amount, seconds - 1)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if exhaustion.check(cid, config.exhaust.storage) then		
		return doPlayerSendCancel(cid, "You're exhausted.")
	end	
	doRemoveItem(item.uid, 1)
	doRegeneration(cid, config.amount, config.time)
	exhaustion.set(cid, config.exhaust.storage, config.exhaust.time)
	return true
end
 
Back
Top