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

Lua exaust on lever(1945)

otuserbyme

New Member
Joined
Nov 10, 2011
Messages
54
Reaction score
1
Can someone explain how I would add exaust to a lever so when used it would not let you use another lever for 20 seconds?
I am using this to have a player use three levers so I want him to wait between uses.Is this the right way to make it, by using exaust?
Thanks for any help, Im still new at lua
 
You can check the time since the server was started with "os.time()" (in milliseconds), save it on a storage value with "setPlayerStorageValue(cid, id, value)", check with "getPlayerStorageValue(cid, id) >= os.time()-20000".
 
You need edit function exhausted
add in your script this
Lua:
if (exhaustion.get (cid, 31185)) then
	doPlayerSendCancel (cid, "Sorry, you can not use this item too fast!")
return TRUE
else
	exhaustion.set(cid, 31185, 1)
	end
 
And incase you don't have those functions, a simple google search:
Code:
exhaustion =
{
	check = function (cid, storage)
		if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
			return false
		end

		return getPlayerStorageValue(cid, storage) >= os.time(t)
	end,

	get = function (cid, storage)
		if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
			return false
		end

		local exhaust = getPlayerStorageValue(cid, storage)
		if(exhaust > 0) then
			local left = exhaust - os.time(t)
			if(left >= 0) then
				return left
			end
		end

		return false
	end,

	set = function (cid, storage, time)
		setPlayerStorageValue(cid, storage, os.time(t) + time)
	end,

	make = function (cid, storage, time)
		local exhaust = exhaustion.get(cid, storage)
		if(not exhaust) then
			exhaustion.set(cid, storage, time)
			return true
		end

		return false
	end
}
 
Back
Top