View Single Post
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Old
  (#14)
KaCaT
Moderator
 
Status: Offline
Posts: 55
Join Date: Dec 2003
Default Re: NEW STEAM: Failure on detecting round, how do YOU do it? - 16-02-2004

Below is the code that I'm using to detect a new round in CS 1.6 (adapted from statsme):

Code:
extern float g_fTimeNewRound;
Code:
void BotClient_CS_TextMsg (void *p, int bot_index)
{
 static bool bWillRestart;
 if (state == 0)
 {
  state++;
  return;
 }
 else if (state == 1)
 {
  bWillRestart = FALSE;

  if (strncmp("#Game_C", (char *)p , 7) == 0) // "Game Commencing!"
   g_fTimeNewRound = gpGlobals->time + 3.07;
  else if (strncmp("#Game_w", (char *)p , 7) == 0) // "The game will restart in ..."
   bWillRestart = TRUE;
 }
 else if (state == 2)
 {
  if (!bWillRestart)
   return;

  g_fTimeNewRound = gpGlobals->time + atoi((char *)p);
 }
 state++;
}
Code:
void BotClient_CS_SendAudio (void *p, int bot_index)
{
 if (state == 0)
 {
  state++;
  return;
 }
 else if (state == 1)
 {
  if ((strcmp((char *)p, "%!MRAD_terwin") == 0) || // "Terrorists Win!"
   (strcmp((char *)p, "%!MRAD_ctwin") == 0) || // "Counter-Terrorists Win!"
   (strcmp((char *)p, "%!MRAD_rounddraw") == 0)) // "Round Draw!"
  {
   g_fTimeNewRound = gpGlobals->time + 5.07;
  }
 }
}
in StartFrame()
Code:
if (g_fTimeNewRound && (g_fTimeNewRound < gpGlobals->time))
  {
   g_fTimeNewRound = 0;
   // New round detected, do what you want to do now


IvPBot - Improved version of Podbot
  
Reply With Quote