Time Delay

Posted by Neves on Wed 24 Jul 2002 10:53 PM — 5 posts, 22,215 views.

USA #0
I'm interested in there being a slight delay in the quitting sequence, but I'm not sure what command to use.

What I want is:
ch_printf( ch, "You pack your bags and prepare to leave.\n\r" );
<Delay of two seconds>
ch_printf( ch, "You pick up your bags and leave the game..." );

Does anyone know a way I can set it to have a two second delay between these two ch_printfs?
USA #1
I'm pretty sure that C has a sleep() function...
Australia Forum Administrator #2
The sleep function won't work the way you want - if you used it all players would have a 2 second delay, not just the one who was quitting.

You could do it by changing the status of the player (eg. to CON_QUITTING) and detect that in the nanny routine.
USA #3
I'm not sure exactly what you mean, I know how to change him to CON_QUITTING, but what would I add to the nanny function to send a delay only to that specific player?

-Nev
Australia Forum Administrator #4
Upon thinking about it, I withdraw that suggestion. :)

That would only work if they typed something.

You would have to somehow put a flag on that player that got picked up in the timer loop (update loop) that does things periodically (like make you thirsty).

However maybe a combination would do it. Set the status to CON_QUITTING, so they can't type any more commands (if you get a command in nanny when the status is quitting, you could say "you are leaving now"). Then in the update routine, if you detect that status, send the second message and disconnect them.