The Place to Start


Round Based gamemode (quick) 
Mr_Grim
Hard


Round Based gamemode (quick)
It aint no cut n' paster tut, that's for sure. You will need to define the functions/variables etc in gamerules.h and replace GameRules:: with what ever it should really be.
Still, here it is...

GameRules::GameRules()
{
  // set to checking mode
  // wait 40 seconds before first check,
  // so ppl can join, choose team (what ever)
  m_RoundState = RND_CHECKING;
  m_RoundTime = gpGlobals->time + 40;
  // bla bal bla (rest of stuff)
}


add to GameRules::Think()

if ((m_RoundState == RND_CHECKING) or (m_RoundState == RND_CHECK_RESTART))
{
  if (m_RoundTime < gpGlobals->time)
    CheckRoundStart ();
}

if (m_RoundState === RND_PRESTART)
{
  SetupRound();
  return;
}

if (m_RoundState == RND_START)
{

  if (m_RoundTime < gpGlobals->time)
  {
    m_RoundTime = 0;

    float flRoundLimit = CVAR_GET_FLOAT("mp_roundtimelimit") * 60;
                
    m_RoundTime = gpGlobals->time + flRoundLimit;
    }
  m_RoundState = RND_DURING;
}

if (m_RoundState == RND_DURING)
{
  if (m_RoundTime && (m_RoundTime < gpGlobals->time))
    RoundOutOfTime ();
}

if (m_RoundState == MATCH_FINISHED)
{
  if (m_RoundTime < gpGlobals->time)
    RoundWinner ();
}

>>>

GameRules::CheckRoundStart ()
{
// bla bla bla etc etc
// Reasons for round starting.
// Make sure teams are even and so on

// no delay coz we don't want teams etc
// to change before we start
  if (start)
  {
    m_RoundTime = 0;
    m_RoundState = RND_PRESTART;
  }
  else
  {
   // wait another 20 seconds before checking
    m_RoundTime = gpGlobals->time + 20;
    m_RoundState = RND_CHECKING;
   // might also wanna check for ppl
   // who can be spawned... kinda like
   // a practice time before the main event
  }
}

>>>>

GameRules::SetupRound ()
{
// bla bla bla etc etc
// Respawn all the players
// remove corpses etc

// slight delay, so you can add spawn
// protection, count down etc
// eg. Lights! Camera! Action! in AHL
  m_RoundTime = gpGlobals->time + 4.0;
  m_RoundState = RND_START;

// go through all the players and
// see who is 'particpating' and record this
// ppl who shouldn't be in, ghost em'
  m_particpants = 0;
  int living = 0;
  for (i = 1; i <= gpGlobals->maxClients; i++)
  {
    CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex (i);

    if (!pPlayer)
      continue;

    // remove weapons
    if (pPlayer->pev->weapons)
      pPlayer->RemoveAllItems (TRUE);

    // should they spawn?
    if (!pPlayer-> something somethin)
    {
      // ghost em'
      continue;
    }
    
    pPlayer->Spawn();
    pPlayer->m_lives = 1;
    living++;
  }
  m_particpants = living;
}

>>>

GameRules::RoundOutOfTime ()
{
  // add what ever you want
  // perhaps figure out who one by number 
  // of kills in a row or something??
  // tell ppl it ended?
  m_RoundState = RND_CHECK_RESTART;
  m_RoundTime = gpGlobals->time + 3.5;
}

>>>

GameRules::RoundWinner ()
{
  // tell ppl who one
  // eg. Last person alive
  m_RoundState = RND_CHECK_RESTART;
  m_RoundTime = gpGlobals->time + 3.5;
}

>>>

GameRules::PlayerKilled bla bla bla
{
  // add something like this to it
  p_victim->m_lives--:
  if (p_victim->m_lives == 0)
    m_participants--;
  CheckRoundOver();
}

>>>
GameRules::Disconnected bla bla bla
{
   // bla bla bla
   // one less player, so say so
    m_participants--;
  CheckRoundOver();
}
>>>

// call each frame possibly?
// your choice
GameRules::CheckRoundOver()
{
  if (m_participants > 1)
    return;

  m_RoundTime = gpGlobals->time + 3.5;
  m_RoundState = RND_FINISHED;
}

>>>

// this is where you stop them respawning
GameRules::FPlayerCanRespawn ( bla bla )
{
  pPlayer->pev->nextthink = -1;
  pPlayer->pev->button = 0;
  pPlayer->m_iRespawnFrames = 0;

  if (gpGlobals->time < (pPlayer->m_fDeadTime + 4))
    return FALSE;
  // make em' a ghost
  pPlayer->pev->movetype = MOVETYPE_NONE;
  pPlayer->pev->solid = SOLID_NOT;
  pPlayer->pev->takedamage = DAMAGE_NO;
  pPlayer->pev->deadflag = DEAD_NO;
  pPlayer->m_iHideHUD |= (HIDEHUD_WEAPONS | HIDEHUD_HEALTH);

  return FALSE;
}

>>

GameRules::PlayerSpawn 
{
  if (m_RoundState >= RND_PRESTART)
     // make em' a ghost
      // bla bla bla

  // etc etc 
}

Any questions or suggestions should be sent to me: mr_grim@telefragged.com