Jump to content

Simple timer

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
im-not-alive

im-not-alive

    Newbie

  • Members
  • Pip
  • 4 posts
I'm developing a "private server" for an online game and I'm basically reading commands from different files, example:
message = You search the crate . . .

anim = 881

wait = 2

message = You find nothing. 

Theoretically what it should do is send the player a message saying "You search the crate . . .", and then a simple animation comes up and wait 2 seconds before displaying the message "You find nothing." The problem is that the delay happens at the begging of the script so it waits 2 seconds, and then it does the animation and sends both of the messages at the same time.

This should be useful:
[HIGHLIGHT="Java"] if(token.startsWith("wait"))
{
try
{
Thread.sleep(Integer.parseInt(token3[0]) * 1000);
}
catch(Exception e)
{
}
}[/HIGHLIGHT]

Any help is highly appreciated; thanks in advance.

#2
Arkie

Arkie

    Learning Programmer

  • Members
  • PipPipPip
  • 92 posts
either use a seperate thread or a timertask.