Whats the best way to do "timers"

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

poppop
Posts: 57
Joined: 07 Jul 2007, 10:24

Whats the best way to do "timers"

Postby poppop » 31 Aug 2007, 10:17

Alright guys,

I want to add a timer to my game, to limit players to a set amount of time.

How should this be done server side?

As a room variable or server variable.

And how is the best way to do it?

Thanks.
Ganius
Posts: 92
Joined: 13 Feb 2007, 12:49

Postby Ganius » 31 Aug 2007, 14:40

User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 06 Sep 2007, 02:24

What if my interval never got cleared? :P

I get this error 2007/09/06 10:41:21.672 - [ WARNING ] [id: 46] (JavascriptExtension$IntervalExecutor.run): SetInterval Error: Wrapped java.lang.NullPointerException (gm_Test.as#230)

I restarted SFS through the admin tool but it still logs every second. I was trying to destroy a room this way:


Code: Select all

if (evt.name == "userExit" || evt.name == "userLost") {
      trace(evt.name);
      // get the user id
      var uId = evt["userId"];
      // get the playerId of the user we have lost
      // var oldPid = evt["oldPlayerIndex"];
      var u = users[uId];
      // Let's remove the player from the list
      delete users[uId];
      numPlayers--;
      gameStarted = false;
      
      if (numPlayers < 1) {
         // destroy this room
         trace("numPlayers: " + numPlayers);
         clearInterval(countdown);
         delete countdown;
         destroyMe = setInterval("deleteMe", 5000); // this is line 230 in gm_Test.as
      }
      
   }
}

function deleteMe(){
   var zone = _server.getCurrentZone();
   var ok = _server.destroyRoom(zone, currentRoomId);
   trace("Destroy room id: " + currentRoomId + " in Zone: " + zone.getName());
   trace("Destroyed? : " + ok);
   
   if(ok){
      clearInterval(destroyMe);
   }
}


The interval did not get cleared because there seemed to be a problem with var zone = _server.getCurrentZone() i think // should have done this in init?

So the log shows the error message every 5 secs. Is there a good way to kill intervals globally? Or can i restart smartfox fully through admin tool?

I am using smartfox remotely and do not have access to the batch file. How i restart smartfox is using admin tool. So if I click on Halt, I will need to wait for system admin to run it back again :cry: Any solutions?

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 35 guests