//========================================================= // ClientUserInfoChanged //========================================================= void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ) { char text[1024]; // prevent skin/color/model changes char *mdls = g_engfuncs.pfnInfoKeyValue( infobuffer, "model" ); if ( !stricmp( mdls, pPlayer->TeamID() ) ) return; if ( defaultteam.value ) { int clientIndex = pPlayer->entindex(); g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->TeamID() ); g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->TeamID() ); sprintf( text, "* Not allowed to change teams in this game!\n" ); UTIL_SayText( text, pPlayer ); return; } if ( defaultteam.value || !IsValidTeam( mdls ) ) { int clientIndex = pPlayer->entindex(); g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->TeamID() ); sprintf( text, "* Can't change team to \'%s\'\n", mdls ); UTIL_SayText( text, pPlayer ); sprintf( text, "* Server limits teams to \'%s\'\n", m_szTeamList ); UTIL_SayText( text, pPlayer ); return; } // notify everyone of the team change sprintf( text, "* %s has changed to team \'%s\'\n", STRING(pPlayer->pev->netname), mdls ); UTIL_SayTextAll( text, pPlayer ); UTIL_LogPrintf( "\"%s<%i><%s><%s>\" joined team \"%s\"\n", STRING(pPlayer->pev->netname), GETPLAYERUSERID( pPlayer->edict() ), #ifdef USE_UPP UPPUtil_GetNetworkID(pPlayer->edict()).c_str(), #else AvHSUGetPlayerAuthIDString( pPlayer->edict() ).c_str(), #endif pPlayer->TeamID(), mdls ); ChangePlayerTeam( pPlayer, mdls, TRUE, TRUE ); // recound stuff RecountTeams(); }
void AvHNexus::setGeneratePerformanceData(const edict_t* edict, const bool generate) { //TODO: check permission to do this before allowing it Nexus::setGeneratePerformanceData(generate); CBaseEntity* player = getEntity(edict); if(player && AvHNexus::getGeneratePerformanceData()) { UTIL_SayText("Nexus Profiling is now ON", player); } else { UTIL_SayText("Nexus Profiling is now OFF", player); } }
//========================================================= // 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(); }
//========================================================= // ClientUserInfoChanged //========================================================= void CTeamplayRules::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ) { char text[1024]; // prevent skin/color/model changes char *mdls = engine->InfoKeyValue( infobuffer, "model" ); if ( !stricmp( mdls, pPlayer->TeamName() ) ) return; if ( defaultteam.GetFloat() ) { int clientIndex = pPlayer->entindex(); engine->SetClientKeyValue( clientIndex, engine->GetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->TeamName() ); engine->SetClientKeyValue( clientIndex, engine->GetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->TeamName() ); UTIL_SayText( "Not allowed to change teams in this game!\n", pPlayer ); return; } if ( defaultteam.GetFloat() || !IsValidTeam( mdls ) ) { int clientIndex = pPlayer->entindex(); engine->SetClientKeyValue( clientIndex, engine->GetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->TeamName() ); Q_snprintf( text,sizeof(text), "Can't change team to \'%s\'\n", mdls ); UTIL_SayText( text, pPlayer ); Q_snprintf( text,sizeof(text), "Server limits teams to \'%s\'\n", m_szTeamList ); UTIL_SayText( text, pPlayer ); return; } // notify everyone of the team change if ( Q_strlen( STRING(pPlayer->pl.netname) ) > 0 ) { Q_snprintf( text,sizeof(text), "%s has changed to team \'%s\'\n", STRING(pPlayer->pl.netname), mdls ); UTIL_SayTextAll( text, pPlayer ); } UTIL_LogPrintf( "\"%s<%i>\" changed to team %s\n", STRING( pPlayer->pl.netname ), engine->GetPlayerUserId( pPlayer->edict() ), mdls ); ChangePlayerTeam( pPlayer, mdls, true, true ); // recound stuff RecountTeams(); }
//--------------------------------------------------------------------------------- // Purpose: Say to all //--------------------------------------------------------------------------------- void SayToAll(const int colour, bool echo, const char *fmt, ...) { va_list argptr; char tempString[1024]; player_t server_player; bool found_player = false; if (war_mode) { return; } va_start ( argptr, fmt ); vsnprintf( tempString, sizeof(tempString), fmt, argptr ); va_end ( argptr ); MRecipientFilter mrf; mrf.MakeReliable(); mrf.RemoveAllRecipients(); if (echo) OutputToConsole(NULL, "%s\n", tempString); for (int i = 1; i <= max_players; i++) { server_player.index = i; if (!FindPlayerByIndex(&server_player)) { continue; } if (server_player.is_bot) { continue; } found_player = true; mrf.AddPlayer(i); if (!(gpManiGameType->IsGameType(MANI_GAME_CSS) || gpManiGameType->IsGameType(MANI_GAME_CSGO))) { if (echo) OutputToConsole(&server_player, "%s\n", tempString); } } if (found_player) { UTIL_SayText(colour, &mrf, tempString); } }
//========================================================= // 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(); } } }
void _print_chat(class CBasePlayer *pPlayer, const char *fmt, ...) { static char Dest[4096]; va_list ap; va_start(ap, fmt); vsnprintf(Dest, sizeof(Dest), fmt, ap); va_end(ap); if (Q_strlen(Dest) < sizeof(Dest) - 2) Q_strcat(Dest, "\n"); else Dest[Q_strlen(Dest) - 1] = '\n'; UTIL_SayText(Dest, (class CBaseEntity *)pPlayer); }
//--------------------------------------------------------------------------------- // Purpose: Say to player //--------------------------------------------------------------------------------- void SayToPlayer(const int colour, player_t *player, const char *fmt, ...) { va_list argptr; char tempString[1024]; player_t recipient_player; if (war_mode) { return; } va_start ( argptr, fmt ); vsnprintf( tempString, sizeof(tempString), fmt, argptr ); va_end ( argptr ); MRecipientFilter mrf; mrf.MakeReliable(); recipient_player.index = player->index; if (!FindPlayerByIndex(&recipient_player)) { return; } if (recipient_player.is_bot) { return; } mrf.AddPlayer(player->index); if (!(gpManiGameType->IsGameType(MANI_GAME_CSS) || gpManiGameType->IsGameType(MANI_GAME_CSGO))) { OutputToConsole(player, "%s\n", tempString); } // OutputToConsole(NULL, "%s\n", tempString); UTIL_SayText(colour, &mrf, tempString); }
//--------------------------------------------------------------------------------- // Purpose: Say string to specific teams //--------------------------------------------------------------------------------- void SayToTeam ( const int colour, bool ct_side, bool t_side, bool spectator, const char *fmt, ... ) { va_list argptr; char tempString[1024]; if (war_mode) { return; } va_start ( argptr, fmt ); vsnprintf( tempString, sizeof(tempString), fmt, argptr ); va_end ( argptr ); MRecipientFilter mrf; player_t recipient_player; mrf.MakeReliable(); mrf.RemoveAllRecipients(); for (int i = 1; i <= max_players; i++) { recipient_player.index = i; if (!FindPlayerByIndex (&recipient_player)) { continue; } if (recipient_player.is_bot) { continue; } if (ct_side) { if (recipient_player.team == TEAM_B) { mrf.AddPlayer(i); } } if (t_side) { if (recipient_player.team == TEAM_A) { mrf.AddPlayer(i); } } if (gpManiGameType->IsSpectatorAllowed() && spectator) { if (recipient_player.team == gpManiGameType->GetSpectatorIndex()) { mrf.AddPlayer(i); } } } OutputToConsole(NULL, "%s\n", tempString); UTIL_SayText(colour, &mrf, tempString); }
//--------------------------------------------------------------------------------- // Purpose: Say to Dead //--------------------------------------------------------------------------------- void SayToDead(const int colour, const char *fmt, ...) { va_list argptr; char tempString[1024]; player_t recipient_player; bool found_player = false; if (war_mode) { return; } va_start ( argptr, fmt ); vsnprintf( tempString, sizeof(tempString), fmt, argptr ); va_end ( argptr ); MRecipientFilter mrf; mrf.MakeReliable(); mrf.RemoveAllRecipients(); OutputToConsole(NULL, "%s\n", tempString); for (int i = 1; i <= max_players; i++) { recipient_player.index = i; if (!FindPlayerByIndex(&recipient_player)) { continue; } if (recipient_player.is_bot) { continue; } // If player is spectator if (gpManiGameType->IsSpectatorAllowed() && recipient_player.team == gpManiGameType->GetSpectatorIndex()) { mrf.AddPlayer(i); found_player = true; if (!(gpManiGameType->IsGameType(MANI_GAME_CSS) || gpManiGameType->IsGameType(MANI_GAME_CSGO))) { OutputToConsole(&recipient_player, "%s\n", tempString); } continue; } if (recipient_player.is_dead) { mrf.AddPlayer(i); found_player = true; if (!(gpManiGameType->IsGameType(MANI_GAME_CSS) || gpManiGameType->IsGameType(MANI_GAME_CSGO))) { OutputToConsole(&recipient_player, "%s\n", tempString); } continue; } } if (found_player) { UTIL_SayText(colour, &mrf, tempString); } }
//--------------------------------------------------------------------------------- // Purpose: Say admin string to all //--------------------------------------------------------------------------------- void AdminSayToAll ( const int colour, player_t *player, int anonymous, const char *fmt, ... ) { va_list argptr; char tempString[1024]; char admin_final_string[2048]; char non_admin_final_string[2048]; bool found_player = false; bool found_admin = false; va_start ( argptr, fmt ); vsnprintf( tempString, sizeof(tempString), fmt, argptr ); va_end ( argptr ); player_t server_player; if (!player) { snprintf(admin_final_string, sizeof (admin_final_string), "(CONSOLE) : %s", tempString); snprintf(non_admin_final_string, sizeof (non_admin_final_string), "(CONSOLE) %s", tempString); } else { snprintf(admin_final_string, sizeof (admin_final_string), "(ADMIN) %s: %s", player->name, tempString); snprintf(non_admin_final_string, sizeof (non_admin_final_string), "(ADMIN) %s", tempString); } OutputToConsole(NULL, "%s\n", admin_final_string); if (anonymous == 1) { MRecipientFilter mrfadmin; MRecipientFilter mrf; mrf.MakeReliable(); mrfadmin.MakeReliable(); for (int i = 1; i <= max_players; i++) { bool is_admin; is_admin = false; server_player.index = i; if (!FindPlayerByIndex(&server_player)) { continue; } if (server_player.is_bot) { continue; } is_admin = gpManiClient->HasAccess(server_player.index, ADMIN, ADMIN_BASIC_ADMIN); if (is_admin) { found_admin = true; mrfadmin.AddPlayer(i); // OutputToConsole(server_player.entity, "%s\n", admin_final_string); } else { found_player = true; mrf.AddPlayer(i); // OutputToConsole(server_player.entity, "%s\n", non_admin_final_string); } } if (found_player) { UTIL_SayText(colour, &mrf, non_admin_final_string); } if (found_admin) { UTIL_SayText(colour, &mrfadmin, admin_final_string); } } else { for (int i = 1; i <= max_players; i++) { server_player.index = i; if (!FindPlayerByIndex(&server_player)) { continue; } if (server_player.is_bot) { continue; } found_player = true; // OutputToConsole(server_player.entity, "%s\n", admin_final_string); } if (found_player) { MRecipientFilter mrf; mrf.MakeReliable(); mrf.AddAllPlayers(max_players); UTIL_SayText(colour, &mrf, admin_final_string); } } }
//--------------------------------------------------------------------------------- // Purpose: Say from player only to admin //--------------------------------------------------------------------------------- void SayToAdmin ( const int colour, player_t *player, const char *fmt, ... ) { va_list argptr; char tempString[1024]; char final_string[2048]; bool found_player = false; player_t recipient_player; if (war_mode) { return; } va_start ( argptr, fmt ); vsnprintf( tempString, sizeof(tempString), fmt, argptr ); va_end ( argptr ); MRecipientFilter mrf; mrf.MakeReliable(); mrf.RemoveAllRecipients(); snprintf(final_string, sizeof (final_string), "(TO ADMIN) %s: %s", player->name, tempString); OutputToConsole(NULL, "%s\n", final_string); for (int i = 1; i <= max_players; i++) { recipient_player.index = i; if (!FindPlayerByIndex (&recipient_player)) { continue; } if (recipient_player.is_bot) { continue; } if (player->index == i) { mrf.AddPlayer(i); found_player = true; // OutputToConsole(recipient_player.entity, "%s\n", final_string); } else { if (gpManiClient->HasAccess(recipient_player.index, ADMIN, ADMIN_BASIC_ADMIN)) { // This is an admin player mrf.AddPlayer(i); found_player = true; // OutputToConsole(recipient_player.entity, "%s\n", final_string); } } } if (found_player) { UTIL_SayText(colour, &mrf, final_string); } }