//========================================================= // InitHUD //========================================================= void CTeamplayRules::InitHUD( CBasePlayer *pPlayer ) { SetDefaultPlayerTeam( pPlayer ); BaseClass::InitHUD( pPlayer ); RecountTeams(); /* TODO this has to be rewritten, maybe add a new USERINFO cvar "team" const char *team = engine->GetClientConVarValue( pPlayer->entindex(), "cl_team" ); // update the current player of the team he is joining char text[1024]; if ( !strcmp( mdls, pPlayer->TeamName() ) ) { Q_snprintf( text,sizeof(text), "You are on team \'%s\'\n", pPlayer->TeamName() ); } else { Q_snprintf( text,sizeof(text), "You were assigned to team %s\n", pPlayer->TeamName() ); } ChangePlayerTeam( pPlayer, pPlayer->TeamName(), false, false ); if ( Q_strlen( pPlayer->TeamName() ) > 0 ) { UTIL_SayText( text, pPlayer ); } RecountTeams(); */ }
//========================================================= // InitHUD //========================================================= void CTeamplayRules::InitHUD( CBasePlayer *pPlayer ) { SetDefaultPlayerTeam( pPlayer ); BaseClass::InitHUD( pPlayer ); RecountTeams(); char *mdls = engine->InfoKeyValue( engine->GetInfoKeyBuffer( pPlayer->edict() ), "model" ); // update the current player of the team he is joining char text[1024]; if ( !strcmp( mdls, pPlayer->TeamName() ) ) { Q_snprintf( text,sizeof(text), "You are on team \'%s\'\n", pPlayer->TeamName() ); } else { Q_snprintf( text,sizeof(text), "You were assigned to team %s\n", pPlayer->TeamName() ); } ChangePlayerTeam( pPlayer, pPlayer->TeamName(), false, false ); if ( Q_strlen( pPlayer->TeamName() ) > 0 ) { UTIL_SayText( text, pPlayer ); } RecountTeams(); }
//========================================================= // InitHUD //========================================================= void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) { int i; SetDefaultPlayerTeam( pPlayer ); CHalfLifeMultiplay::InitHUD( pPlayer ); // Send down the team names MESSAGE_BEGIN( MSG_ONE, gmsgTeamNames, NULL, pPlayer->edict() ); WRITE_BYTE( num_teams ); for ( i = 0; i < num_teams; i++ ) { WRITE_STRING( team_names[ i ] ); } MESSAGE_END(); RecountTeams(); char *mdls = g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model" ); // update the current player of the team he is joining char text[1024]; if ( !strcmp( mdls, pPlayer->m_szTeamName ) ) { sprintf( text, "* you are on team \'%s\'\n", pPlayer->m_szTeamName ); } else { sprintf( text, "* assigned to team %s\n", pPlayer->m_szTeamName ); } ChangePlayerTeam( pPlayer, pPlayer->m_szTeamName, FALSE, FALSE ); UTIL_SayText( text, pPlayer ); int clientIndex = pPlayer->entindex(); RecountTeams(); // update this player with all the other players team info // loop through all active players and send their team info to the new client for ( i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *plr = UTIL_PlayerByIndex( i ); if ( plr && IsValidTeam( plr->TeamID() ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgTeamInfo, NULL, pPlayer->edict() ); WRITE_BYTE( plr->entindex() ); WRITE_STRING( plr->TeamID() ); MESSAGE_END(); } } }
//========================================================= // InitHUD //========================================================= void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) { int i; SetDefaultPlayerTeam( pPlayer ); CHalfLifeMultiplay::InitHUD( pPlayer ); // Send down the team names MESSAGE_BEGIN( MSG_ONE, gmsgTeamNames, NULL, pPlayer->edict() ); WRITE_BYTE( num_teams ); for ( i = 0; i < num_teams; i++ ) { char theTeamName[256]; strcpy(theTeamName, team_names[i]); // If the team name isn't empty, append # so team name is translated on client if(strcmp(theTeamName, "")) { sprintf(theTeamName, "#%s", team_names[i]); } WRITE_STRING(theTeamName); } MESSAGE_END(); RecountTeams(); // char *mdls = g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model" ); // // update the current player of the team he is joining // char text[1024]; // if ( !strcmp( mdls, pPlayer->m_szTeamName ) ) // { // sprintf( text, "* you are on team \'%s\'\n", pPlayer->m_szTeamName ); // } // else // { // sprintf( text, "* assigned to team %s\n", pPlayer->m_szTeamName ); // } ChangePlayerTeam( pPlayer, pPlayer->TeamID(), FALSE, FALSE ); // UTIL_SayText( text, pPlayer ); int clientIndex = pPlayer->entindex(); RecountTeams(); // // update this player with all the other players team info // // loop through all active players and send their team info to the new client // for ( i = 1; i <= gpGlobals->maxClients; i++ ) // { // CBasePlayer *plr = (CBasePlayer*)UTIL_PlayerByIndex( i ); // if ( plr && IsValidTeam( plr->TeamID() ) ) // { // MESSAGE_BEGIN( MSG_ONE, gmsgTeamInfo, NULL, pPlayer->edict() ); // WRITE_BYTE( plr->entindex() ); // WRITE_STRING( plr->TeamID() ); // MESSAGE_END(); // } // } pPlayer->NeedsTeamUpdate(); }