• 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 What does 'addEvent(function, interval, params)' return?

BeniS

Advanced OT User
Senator
Joined
Aug 8, 2009
Messages
1,850
Reaction score
189
Location
New Zealand
As the title states. I want to get the value returned by the function/event activated but I'm not sure if the addEvent function will return my functions return value.

Does anyone know if it does?
and if not a solution?
 
No. addEvent return 'event id' of started event. Then you can stop this event by funtion: stopEvent(event_id)
For what do you need value returned by event?!
If you want save value you must write it like in example below, store returned value in variable definied above script.

Short example from TFS:
PHP:
local savingEvent = 0

function onSay(cid, words, param, channel)
	if(isNumber(param)) then
		stopEvent(savingEvent)
		save(tonumber(param) * 60 * 1000)
	else
		doSaveServer()
	end
	return true
end

function save(delay)
	doSaveServer()
	if(delay > 0) then
		savingEvent = addEvent(save, delay, delay)
	end
end
When player say /save with number it start event to save server every X minutes, when player say again /save X it stop old event and start new with new time interval.
 
No. addEvent return 'event id' of started event. Then you can stop this event by funtion: stopEvent(event_id)
For what do you need value returned by event?!
If you want save value you must write it like in example below, store returned value in variable definied above script.

Short example from TFS:
PHP:
local savingEvent = 0

function onSay(cid, words, param, channel)
	if(isNumber(param)) then
		stopEvent(savingEvent)
		save(tonumber(param) * 60 * 1000)
	else
		doSaveServer()
	end
	return true
end

function save(delay)
	doSaveServer()
	if(delay > 0) then
		savingEvent = addEvent(save, delay, delay)
	end
end
When player say /save with number it start event to save server every X minutes, when player say again /save X it stop old event and start new with new time interval.

Ya I figured as such. Thanks for the fast help :p

The function I have in the event space returns a value that I need to get. But im calling the function in the addEvent function so I didn't know if I was able to get that returned value from it :S
 
Back
Top