Server Help

Bot Questions - timer starting

pixelsoft - Sat May 24, 2003 10:26 am
Post subject: timer starting
hey, can u tell me the code, how to start a timer (i already have a countdown[0]...), when there are 2 players playing(not speccing!!)?
k0zy - Sat May 24, 2003 11:51 am
Post subject:
Code: Show/Hide
int i=0;

_listnode <Player> *parse = playerlist->head;
while (parse)
{
   Player *p = parse->item;
   if (p->ship != SHIP_Spectator)
      ++i;

   parse = parse->next;
}

if (i == 2)
   countdown[1] = 5;


Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
pixelsoft - Sat May 24, 2003 12:28 pm
Post subject:
thank you... but is this spawn.cpp or spawn.h
?
k0zy - Sat May 24, 2003 5:52 pm
Post subject:
Theres no such code in spawn.h tongue.gif

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
ExplodyThingy - Sun May 25, 2003 8:55 pm
Post subject:
Or if you want, just do this, its how i would do it.

spawn.h;
Code: Show/Hide
class botInfo
{
   int SpecPop;
void CountSpec();
}


spawn.cpp;
Code: Show/Hide
void botInfo::CountSpec()
{
   SpecPop=0;
   _listnode <Player> * parse = playerlist->head;
   Player *p = parse->item;
   while (parse)
   {
      if (p->ship == SHIP_Spectate)
      //Or, if you want to count the FREQ not SHIP
      //if(p->team == /*spec freq*/)
      //put em together to ignore staff like me who play on the spec freq to talk.
         SpecPop++;
      parse = parse->next;
   }
}



Call it on EVENT_PlayerShip, EVENT_PlayerSpec, EVENT_PlayerEnter, and EVENT_PlayerExit. That would re-poll the entire arena every time, as a sort of double check. And in the EVENT_ArenaEnter and EVENT_ArenaLeave, for when the bot moves/spawns.

Added code tags -MGB
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group