I'm developing a "private server" for an online game and I'm basically reading commands from different files, example:
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.
message = You search the crate . . .
anim = 881
wait = 2
message = You find nothing.
This should be useful:
Any help is highly appreciated; thanks in advance.
Thread.sleep(Integer.parseInt(token3) * 1000);
Try doing this animation and waiting inside a background thread so the EventDispatchThread is not blocked by the waiting/sleeping.