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

Solved How to make delay between actions

Nutaharion

New Member
Joined
Oct 29, 2008
Messages
133
Reaction score
4
Location
Poland
Hi everybody,

I need help with making a delay between 2 actions. First is that item appear and after one second it dissapear.

And i don't know what to add between doCreate and doRemove to work it correctly :-(

Lua:
function onStepIn(cid, item, pos)
		doCreateItem(2160, {x=984, y=1148, z=7})
		doRemoveItem(getThingfromPos({x=984, y=1148, z=7, stackpos=1}).uid, 1)
	return true
end
 
Last edited:
use addEvent, ex:
Code:
addEvent(doRemoveItem, 1000, getThingFromPos(...).uid, 1)
or
Code:
addEvent(function() doRemoveItem(...) end, 1000)
?
 
I really don't know how to use addEvent ;-D

I wrote sth like this, but don't working.

Lua:
function time()
end
function onStepIn(cid, item, pos)
		doCreateItem(2160, {x=984, y=1148, z=7})
		addEvent(time, 1000)
		doRemoveItem(getThingfromPos({x=984, y=1148, z=7, stackpos=1}).uid, 1)
	return true
end
 
... I gave you 2 examples, anyways try this:
Code:
function onStepIn(cid, item, pos)
	doCreateItem(2160, {x=984, y=1148, z=7})
	addEvent(function() doRemoveItem(getThingfromPos({x=984, y=1148, z=7, stackpos=1}).uid, 1) print('item removed') end, 1000)
	return true
end
 
The thing you were trying to do (your 2nd post), addEvent doesn't block, if you're a c coder and thought of addEvent as in C's sleep() then no, it doesn't work like that, I would suggest looking at how TFS's Dispatcher & Scheduler work.
 
Back
Top