PDA

View Full Version : Game Timer



wookie
07-06-2004, 11:44 PM
Hi I am a newbie with ES and I just wondering if anyone can point me in the right direction for coding up a Gametimer plugin using Script:

What I want to be able to do is real-time synchronize the start of a game with a countdown.. ie 5,4,3,2,1 PLAY!
It is a two player gameRoom , once the secondplayer has joined the room the countdown should start.

I am trying to get this sorted in my head but I am having troubles...

Is this the right methodology??
1) Player1 connection to game room: register player (room controller)
2) Player1 Client waits and listens for notification of player2 joining
3) Player2 connection to game room: register player, notify Player1
4) Player2 Client listens for Countdown start
5) Player1 as room controller , notifies plugin to start Countdown
6) Player1 Client listens for Countdown Start
7) Plugin broadcasts countdown event to both players.

Can I tell the plugin to send multiple result events at different time Intervals? or does the Client app always have to request the state from the plugin?

Any tips, much appreciated.. :)

peterblaze
07-07-2004, 03:02 AM
Hi wookie,
I don't help You much but I think that:
1) You should initialize Your plugin with "room" scope - becouse You will need one instance of timer for every game , with 'server' scope You will have one timer for every game rooms on server
2) You can try to use setInterval function to build Your timer:
e.g.: gameIntervalID = setInterval("yourTimerFunction", interval);
3) within yourTimerFunction You could use:
server.sendMessage("public", action, variables);
4) after countdown You must kill interval:
e.g.: clearInterval(gameIntervalID);
I think it's possible to run two different intervals in plugin but I didn't test such solution.
TIP:
Please download Jobe example files for PixelCannon Game where Jobe uses interval in his plugin script,
link: http://www.electro-server.com/forum/?f=2&m=16
hth,
Peter