sleep() like function

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
phao
UOX3 Newbie
Posts: 24
Joined: Sat Aug 11, 2007 7:27 pm
Has thanked: 0
Been thanked: 0

sleep() like function

Post by phao »

is there a sleep(seconds) function?

like

Code: Select all

/* command registration .. bla bla bl */
command_TST(socket, cmdstr) {
sleep(2);
BroadcastMessage("tst ok");
}
so when you use 'tst it'll wait 2 seconds before printing that message using broadcast.
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

You can use the OnTimer() function, it dosen't delay the effects in seconds, but rather my miliseconds, so you would be at 2000 instead of 2.

Check out the healing.js and various other "timed delay" scripts. The OnTimer function is used to delay healing from bandages, cure poison, etc.
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Also, given that the scripting engine runs in the same thread, you don't want a sleep function. Not unless you want the whole server to sleep for 2 seconds :)

Stranf's suggestion is best, fire off a 2 second timer and resume from there.
Post Reply