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

Lever that can only be used by all players every 10 minutes

icaro1988

New Member
Joined
Jul 1, 2009
Messages
63
Reaction score
1
Example:
- Player A will and the active lever!
- Soon after the player B will try to activate and get the following message (The lever has been active for another player. Wait 10 minutes to activate it again)

Is it possible?

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

addEvent(wait1,1000,piece1pos)
end	 

function wait1(piece1pos)
local raids = {'Ghazbaran', 'Orshabaal', 'Morgaroth'}
local r = math.random(1,3)
 doExecuteRaid(raids[r])

end


I want to add time to all players in this script, such a delay.
If a player clicks, the next player can click only 10 minutes!

Thanks!
 
Last edited:
Use os.time or global storage with addEvent

Okay, more would show me a script? Just one example


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

addEvent(wait1,1000,piece1pos)
end	 

function wait1(piece1pos)
local raids = {'Ghazbaran', 'Orshabaal', 'Morgaroth'}
local r = math.random(1,3)
 doExecuteRaid(raids[r])

end


I want to add time to all players in this script, such a delay.
If a player clicks, the next player can click only 10 minutes!
 
Last edited:
Code:
local config = {
	raids = {
		"Ghazbaran", "Rats"
	},
	storage = 12211,
	time = 10 * 60
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getGlobalStorageValue(config.storage) < os.time() then
		executeRaid(config.raids[math.random(1, #config.raids)])
		setGlobalStorageValue(config.storage, os.time() + config.time)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait.")
	end
	
	return true
end
 
Code:
local config = {
	raids = {
		"Ghazbaran", "Rats"
	},
	storage = 12211,
	time = 10 * 60
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getGlobalStorageValue(config.storage) < os.time() then
		executeRaid(config.raids[math.random(1, #config.raids)])
		setGlobalStorageValue(config.storage, os.time() + config.time)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait.")
	end
	
	return true
end

Great, solved, thanks, rep ++ for you!

Thanks All
 
Back
Top