void MRecipientFilter::AddAllPlayers(int maxClients)
{
   m_Recipients.RemoveAll();
   int i;
   for ( i = 1; i <= maxClients; i++ )
   {
#if defined ( GAME_CSGO )
      edict_t *pPlayer = PEntityOfEntIndex(i);
#else
	   edict_t *pPlayer = engine->PEntityOfEntIndex(i);
#endif
      if ( !pPlayer || pPlayer->IsFree()) {
         continue;
      }

	  IPlayerInfo *playerinfo = playerinfomanager->GetPlayerInfo( pPlayer );
	  if (!playerinfo || !playerinfo->IsConnected())
	  {
		 continue;
	  }
		  
	  if (playerinfo->IsHLTV())
	  {
		  continue;
	  }

	  if (strcmp(playerinfo->GetNetworkIDString(),"BOT") == 0)
	  {
		  continue;
	  }

	  m_Recipients.AddToTail(i);
   }
} 
void SizzlingStats::SS_PlayerDisconnect( CSizzPluginContext *pPluginContext, edict_t *pEdict )
{
	Msg( "SS_DeletePlayer\n" );
	int ent_index = SCHelpers::EntIndexFromEdict(pEdict);
	if (ent_index != -1)
	{
		if (m_PlayerDataManager.IsValidPlayer(ent_index))
		{
			playerAndExtra_t data = m_PlayerDataManager.GetPlayerData(ent_index);
			data.m_pPlayerData->UpdateRoundStatsData(m_aPropOffsets);
			data.m_pPlayerData->UpdateRoundExtraData(*data.m_pExtraData);

			IPlayerInfo *pInfo = pPluginContext->GetPlayerInfo(ent_index);

			if (m_bTournamentMatchRunning)
			{
				playerWebStats_t stats;
				stats.m_scoreData = data.m_pPlayerData->GetRoundStatsData();
				V_strncpy(stats.m_playerInfo.m_name, pInfo->GetName(), sizeof(stats.m_playerInfo.m_name));
				V_strncpy(stats.m_playerInfo.m_steamid, pInfo->GetNetworkIDString(), sizeof(stats.m_playerInfo.m_steamid));
				V_strncpy(stats.m_playerInfo.m_ip, pPluginContext->GetPlayerIPPortString(ent_index), sizeof(stats.m_playerInfo.m_ip));
				stats.m_playerInfo.m_teamid = pInfo->GetTeamIndex();
				CPlayerClassTracker *pTracker = data.m_pPlayerData->GetClassTracker();
				stats.m_playerInfo.m_mostPlayedClass = pTracker->GetMostPlayedClass();
				stats.m_playerInfo.m_playedClasses = pTracker->GetPlayedClasses();
				m_pWebStatsHandler->EnqueuePlayerStats(stats);
			}
		}

		m_vecMedics.FindAndRemove(ent_index);
		m_PlayerDataManager.RemovePlayer(ent_index);
	}
}
void SizzlingStats::ChatEvent( CSizzPluginContext *pPluginContext, int entindex, const char *pText, bool bTeamChat )
{
	IPlayerInfo *pInfo = pPluginContext->GetPlayerInfo(entindex);
    if (!pInfo)
    {
        return;
    }
	const char *pSteamId = pInfo->GetNetworkIDString();
	// during the match, m_flMatchDuration is the Plat_FloatTime() from when the game started
	// so subtracting gets the time since the match started
	m_pWebStatsHandler->PlayerChatEvent(Plat_FloatTime() - m_flMatchDuration, pSteamId, pText, bTeamChat);
}
Esempio n. 4
0
void CClient :: clientActive ()
{
	// get steam id
	IPlayerInfo *playerinfo = playerinfomanager->GetPlayerInfo( m_pPlayer );

	m_szSteamID = NULL;

	if ( playerinfo )
	{
		// store steam id
		m_szSteamID = (char*)playerinfo->GetNetworkIDString();
	
		// check my access levels
		CAccessClients::checkClientAccess(this);
	}
}
void SizzlingStats::SS_TournamentMatchStarted( CSizzPluginContext *pPluginContext )
{
	Msg( "tournament match started\n" );
	m_bTournamentMatchRunning = true;
	m_flMatchDuration = Plat_FloatTime();

	V_strncpy(m_pHostInfo->m_hostname, pPluginContext->GetHostName(), 64);
	V_strncpy(m_pHostInfo->m_mapname, pPluginContext->GetMapName(), 64);
	V_strncpy(m_pHostInfo->m_bluname, pPluginContext->GetBluTeamName(), 32);
	V_strncpy(m_pHostInfo->m_redname, pPluginContext->GetRedTeamName(), 32);
	m_pHostInfo->m_hostip = m_refHostIP.GetInt();
	V_strncpy(m_pHostInfo->m_ip, m_refIP.GetString(), 32);
	m_pHostInfo->m_hostport = m_refHostPort.GetInt();
	m_pHostInfo->m_roundduration = m_flRoundDuration;
	m_pWebStatsHandler->SetHostData(*m_pHostInfo);

	// record demos if the cvar is non-zero
	if (record_demos.GetBool())
	{
		m_STVRecorder.StartRecording(pPluginContext, m_pHostInfo->m_mapname);
	}

	CTFPlayerWrapper player;
	for (int i = 1; i <= MAX_PLAYERS; ++i)
	{
		if (m_PlayerDataManager.IsValidPlayer(i))
		{
			player.SetPlayer(pPluginContext->BaseEntityFromEntIndex(i));
			IPlayerInfo *pInfo = pPluginContext->GetPlayerInfo(i);
			playerInfo_t info;
			V_strncpy(info.m_name, pInfo->GetName(), sizeof(info.m_name));
			V_strncpy(info.m_steamid, pInfo->GetNetworkIDString(), sizeof(info.m_steamid));
			V_strncpy(info.m_ip, pPluginContext->GetPlayerIPPortString(i), sizeof(info.m_ip));
			info.m_teamid = pInfo->GetTeamIndex();
			info.m_mostPlayedClass = player.GetClass();
			m_pWebStatsHandler->EnqueuePlayerInfo(info);
		}
	}

	// set the api key
	m_pWebStatsHandler->SetApiKey(apikey.GetString());

	// send the initial match info to the web
	m_pWebStatsHandler->SendGameStartEvent();
}
void CSizzPluginContext::GetSteamIDString( int userid, char *dest, int buff_size )
{
	if (dest && (buff_size > 0))
	{
		int ent_index = EntIndexFromUserID(userid);
		if (ent_index != -1)
		{
			IPlayerInfo *pInfo = GetPlayerInfo(ent_index);
			if (pInfo)
			{
				const char *src = pInfo->GetNetworkIDString();
				if (src)
				{
					V_strncpy(dest, src, buff_size);
				}
			}
		}
	}
}
void SizzlingStats::SS_EndOfRound( CSizzPluginContext *pPluginContext )
{
	for (int i = 1; i <= MAX_PLAYERS; ++i)
	{
		if (m_PlayerDataManager.IsValidPlayer(i))
		{
			playerAndExtra_t data = m_PlayerDataManager.GetPlayerData(i);
			data.m_pPlayerData->UpdateRoundStatsData(m_aPropOffsets);
			data.m_pPlayerData->UpdateRoundExtraData(*data.m_pExtraData);

			IPlayerInfo *pInfo = pPluginContext->GetPlayerInfo(i);

			if (m_bTournamentMatchRunning)
			{
				playerWebStats_t stats;
				stats.m_scoreData = data.m_pPlayerData->GetRoundStatsData();
				V_strncpy(stats.m_playerInfo.m_name, pInfo->GetName(), sizeof(stats.m_playerInfo.m_name));
				V_strncpy(stats.m_playerInfo.m_steamid, pInfo->GetNetworkIDString(), sizeof(stats.m_playerInfo.m_steamid));
				V_strncpy(stats.m_playerInfo.m_ip, pPluginContext->GetPlayerIPPortString(i), sizeof(stats.m_playerInfo.m_ip));
				stats.m_playerInfo.m_teamid = pInfo->GetTeamIndex();
				CPlayerClassTracker *pTracker = data.m_pPlayerData->GetClassTracker();
				stats.m_playerInfo.m_mostPlayedClass = pTracker->GetMostPlayedClass();
				stats.m_playerInfo.m_playedClasses = pTracker->GetPlayedClasses();
				m_pWebStatsHandler->EnqueuePlayerStats(stats);
			}

			if (pInfo->GetTeamIndex() > 1)
			{
				SS_DisplayStats(pPluginContext, i);
			}
		}
	}

	if (m_bTournamentMatchRunning)
	{
		m_pHostInfo->m_roundduration = m_flRoundDuration;
		m_pWebStatsHandler->SetHostData(*m_pHostInfo);
		m_pWebStatsHandler->SendStatsToWeb();
	}
}
Esempio n. 8
0
void XmlReport::writeJoueur(ticpp::Element * eJoueurs, ClanMember * player)
{
    IPlayerInfo * pInfo = player->getPlayerInfo();
    PlayerScore * stats = player->getCurrentScore();

    if (isValidPlayerInfo(pInfo)) // excludes SourceTv
    {
        ticpp::Element * eJoueur = new ticpp::Element("joueur");
        eJoueur->SetAttribute("steamid", pInfo->GetNetworkIDString());

        ticpp::Element * ePseudo = new ticpp::Element("pseudo", pInfo->GetName());
        eJoueur->LinkEndChild(ePseudo);

        ticpp::Element * eKills = new ticpp::Element("kills", stats->kills);
        eJoueur->LinkEndChild(eKills);

        ticpp::Element * eDeaths = new ticpp::Element("deaths", stats->deaths);
        eJoueur->LinkEndChild(eDeaths);

        eJoueurs->LinkEndChild(eJoueur);
    }
}
//---------------------------------------------------------------------------------
// Purpose: Builds up a list of players that are 'kickable'
//---------------------------------------------------------------------------------
void ManiReservedSlot::BuildPlayerKickList( player_t *player_ptr, int *players_on_server )
{
	player_t	temp_player;
	active_player_t active_player;

	FreeList((void **) &active_player_list, &active_player_list_size);

	for (int i = 1; i <= max_players; i ++)
	{
#if defined ( GAME_CSGO )
		edict_t *pEntity = PEntityOfEntIndex(i);
#else
		edict_t *pEntity = engine->PEntityOfEntIndex(i);
#endif
		if( pEntity && !pEntity->IsFree())
		{
			if ( player_ptr && ( pEntity == player_ptr->entity ) )
				continue;

			IPlayerInfo *playerinfo = playerinfomanager->GetPlayerInfo( pEntity );
			if (playerinfo && playerinfo->IsConnected())
			{
				Q_strcpy(active_player.steam_id, playerinfo->GetNetworkIDString());
				if (FStrEq("BOT", active_player.steam_id))
				{
					continue;
				}

				INetChannelInfo *nci = engine->GetPlayerNetInfo(i);
				if (!nci)
				{
					continue;
				}

				active_player.entity = pEntity;

				active_player.ping = nci->GetAvgLatency(0);
				const char * szCmdRate = engine->GetClientConVarValue( i, "cl_cmdrate" );
				int nCmdRate = (20 > Q_atoi( szCmdRate )) ? 20 : Q_atoi(szCmdRate);
				active_player.ping -= (0.5f/nCmdRate) + TICKS_TO_TIME( 1.0f ); // correct latency

				// in GoldSrc we had a different, not fixed tickrate. so we have to adjust
				// Source pings by half a tick to match the old GoldSrc pings.
				active_player.ping -= TICKS_TO_TIME( 0.5f );
				active_player.ping = active_player.ping * 1000.0f; // as msecs
				active_player.ping = ((5 > active_player.ping) ? 5:active_player.ping); // set bounds, dont show pings under 5 msecs

				active_player.time_connected = nci->GetTimeConnected();
				Q_strcpy(active_player.ip_address, nci->GetAddress());
				if (gpManiGameType->IsSpectatorAllowed() &&
					playerinfo->GetTeamIndex () == gpManiGameType->GetSpectatorIndex())
				{
					active_player.is_spectator = true;
				}
				else
				{
					active_player.is_spectator = false;
				}
				active_player.user_id = playerinfo->GetUserID();
				Q_strcpy(active_player.name, playerinfo->GetName());

				if ( players_on_server )
					*players_on_server = *players_on_server + 1;

				active_player.kills = playerinfo->GetFragCount();
				active_player.deaths = playerinfo->GetDeathCount();
				Q_strcpy(temp_player.steam_id, active_player.steam_id);
				Q_strcpy(temp_player.ip_address, active_player.ip_address);
				Q_strcpy(temp_player.name, active_player.name);
				temp_player.is_bot = false;

				if (IsPlayerInReserveList(&temp_player))
				{
					continue;
				}

				active_player.index = i;

				if (mani_reserve_slots_include_admin.GetInt() == 1 &&
					gpManiClient->HasAccess(active_player.index, ADMIN, ADMIN_BASIC_ADMIN))
				{
					continue;
				}

				if (gpManiClient->HasAccess(active_player.index, IMMUNITY, IMMUNITY_RESERVE))
				{
					continue;
				}

				AddToList((void **) &active_player_list, sizeof(active_player_t), &active_player_list_size);
				active_player_list[active_player_list_size - 1] = active_player;
			}
		}
	}
}
Esempio n. 10
0
//---------------------------------------------------------------------------------
// Purpose: Process Game Frame
//---------------------------------------------------------------------------------
void ManiAutoMap::GameFrame(void)
{
	if (war_mode || 
		mani_automap.GetInt() == 0 || 
		ignore_this_map || 
		automap_list_size == 0) return;

	if (g_RealTime < trigger_time) return;

	trigger_time += 15;

	int	players = 0;
	bool include_bots = mani_automap_include_bots.GetBool();
	int	threshold = mani_automap_player_threshold.GetInt();

	// Count players
	for (int i = 1; i <= max_players; i++)
	{
		// Faster than FindPlayerByIndex()
#if defined ( GAME_CSGO )
		edict_t *pEntity = PEntityOfEntIndex(i);
#else
		edict_t *pEntity = engine->PEntityOfEntIndex(i);
#endif
		if(pEntity && !pEntity->IsFree() )
		{
			IPlayerInfo *playerinfo = playerinfomanager->GetPlayerInfo( pEntity );
			if (playerinfo && playerinfo->IsConnected())
			{
				if (playerinfo->IsHLTV()) continue;
				if (!include_bots && strcmp(playerinfo->GetNetworkIDString(), "BOT") == 0) continue;

				players ++;
				if (players > threshold)
				{
					// Broken threshold so just ignore, but reset the timeout
					this->ResetTimeout(mani_automap_timer.GetInt());
					return;
				}
			}
		}
	}

	// Need to change map
	if (mani_automap_set_nextmap.GetInt() != 0)
	{
		set_next_map = true;
	}
	else
	{
		set_next_map = false;
	}

	int map_choice = this->ChooseMap();

	override_changelevel = 0;
	override_setnextmap = false;
	ignore_this_map = true;
	LogCommand (NULL, "Autochange to map %s while server idle\n", automap_list[map_choice].map_name);
	SetChangeLevelReason("Automap changed map");

 	char	changelevel_command[128];
	snprintf(changelevel_command, sizeof(changelevel_command), "changelevel %s\n", automap_list[map_choice].map_name);
	engine->ServerCommand(changelevel_command);
}