• 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!

Exchaustion Library

Tairens

Member
Joined
Sep 23, 2007
Messages
90
Reaction score
5
Hello ;)
I want give you library for creating, setting, removing exhaustion.
Code:
Exhaustion = {}
Exhaustion.__index = Exhaustion

function Exhaustion.__construct(cid, storage)
	local new = {}
	setmetatable(new, Exhaustion)
	new.cid = cid
	new.storage = storage
	return new
end

function Exhaustion:isExhausted()
	if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
		return false
	end
	return getPlayerStorageValue(self.cid, self.storage) >= os.time(t)
end

function Exhaustion:getTime()
	if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
		return 0
	end
	return getPlayerStorageValue(self.cid, self.storage)
end

function Exhaustion:addTime(extraTime)
	return setPlayerStorageValue(self.cid, self.storage, getPlayerStorageValue(self.cid, self.storage) + extraTime)
end

function Exhaustion:makeNew(time)
	return setPlayerStorageValue(self.cid, self.storage, os.time(t) + time)
end

function Exhaustion:clean()
	return setPlayerStorageValue(self.cid, self.storage, 0)
end

How use it:
Code:
function onSay(cid, words, param)
local Exhaustion = Exhaustion.__construct(cid, 1500)
	if(Exhaustion:isExhausted == true) then
		doPlayerSendTextMessage(cid, 22, 'You are exhausted. You must wait:'..Exhaustion:getTime()..'.')
	else
		doCreatureAddHealth(cid, 100)
		doPlayerSendTextMessage(cid, 22, 'You are not exhuasted!')
		Exhaustion:makeNew(5)
	end
	if(getCreatureHealth(cid) < 250) then
		Exhaustion:remove()
	elseif(getCreatureHealth(cid) > 1000) then
		Exhaustion:addTime(2)
	end
return true
end

:ninja:
 
very nice and useful, but I have a question:
Let's say I have ItemA and ItemB, and both use the exhaustion script and
exhaust players for 5 minutes, if I use ItemA and get exhausted, will I be
able to use ItemB? or will it say "You are exhausted."?
 
Back
Top