Example #1
0
bool CCSSBot :: startGame ()
{
    // do whatever is necessary here to join the game...
    IPlayerInfo* pInfo = playerinfomanager->GetPlayerInfo(m_pEdict);

    if ( pInfo->GetTeamIndex() == 0 )
    {
        pInfo->ChangeTeam(randomInt(2,3));
    }

    return (pInfo->GetTeamIndex() != 0);
}
void SizzlingStats::CheckPlayerDropped( CSizzPluginContext *pPluginContext, int victimIndex )
{
	for (int i = 0; i < m_vecMedics.Count(); ++i)
	{
		int medIndex = m_vecMedics[i];
		SS_PlayerData *pMedData = m_PlayerDataManager.GetPlayerData(medIndex).m_pPlayerData;
		SS_PlayerData *pVictimData = m_PlayerDataManager.GetPlayerData(victimIndex).m_pPlayerData;

		IPlayerInfo *pMedPlayerInfo = pPluginContext->GetPlayerInfo(medIndex);
		IPlayerInfo *pVictimPlayerInfo = pPluginContext->GetPlayerInfo(victimIndex);
		if ( pMedPlayerInfo->GetTeamIndex() == pVictimPlayerInfo->GetTeamIndex() )
		{
			using namespace SCHelpers;
			CTFPlayerWrapper medic(pMedData->GetBaseEntity());
			
			//CBaseEntity *pMedigun = pPluginContext->BaseEntityFromBaseHandle(hMedigun);

			//const char *szWeapon = SCHelpers::GetClassName(pMedigun);
			//if ( szWeapon && SCHelpers::FStrEq(szWeapon, "tf_weapon_medigun") )
			//{
				float flChargeLevel = medic.GetChargeLevel(pPluginContext);
				bool bReleasingCharge = medic.IsReleasingCharge();

				if (flChargeLevel == 1.0f || bReleasingCharge)
				{
					CTFPlayerWrapper victim(pVictimData->GetBaseEntity());
					Vector *victimPos = victim.GetPlayerOrigin();
					Vector *medPos = medic.GetPlayerOrigin();
		
					vec_t distance = victimPos->DistToSqr( *medPos );
					SS_AllUserChatMessage( pPluginContext, UTIL_VarArgs("distance: %.2f\n", distance) );
					if (distance <= 230400.0f) // ~480 units is max target distance for medigun
					{
						IHandleEntity *pMedHandleEnt = pPluginContext->HandleEntityFromEntIndex(medIndex);
						// slot 2 because we want the medigun
						IHandleEntity *pMedigunHandleEnt = pPluginContext->HandleEntityFromEntIndex(medic.GetWeapon(2)->GetEntryIndex());

						Ray_t ray;
						ray.Init(*medPos, *victimPos);
						CTraceFilterSkipTwo traceFilter(pMedHandleEnt, pMedigunHandleEnt);
						trace_t trace;
						enginetrace->TraceRay(ray, MASK_SHOT_HULL, &traceFilter, &trace);
						if (!trace.DidHit())
						{
							SS_AllUserChatMessage( pPluginContext, "player dropped\n" );
						}
					}
				}
			//}
		}
	}
}
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);
	}
}
Example #4
0
int NczPlayer::aimingAt()
{
	trace_t trace;
	Ray_t ray;

	edict_t* edict = GetEdict();
	if(!edict) return -1;
	IPlayerInfo* playerinfo = GetPlayerInfo();
	if(!playerinfo) return -1;
	CBotCmd cmd = playerinfo->GetLastUserCommand();

	Vector earPos;
	CIFaceManager::GetInstance()->GetIclients()->ClientEarPosition(edict, &earPos);
	Vector eyePos = earPos;

	QAngle eyeAngles = cmd.viewangles;
	Vector vEnd;
	AngleVectors(eyeAngles, &vEnd);
	vEnd = vEnd * 8192.0f + eyePos;
	
	ray.Init(eyePos,vEnd);
	CIFaceManager::GetInstance()->GetItrace()->TraceRay( ray, (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_DEBRIS | CONTENTS_HITBOX), NULL, &trace );
	
	edict_t* target = CIFaceManager::GetInstance()->GetIents()->BaseEntityToEdict(trace.m_pEnt);
	if ( target && !Helpers::IndexOfEdict(target) == 0 && !trace.allsolid )
	{
		if(!Helpers::isValidEdict(target)) return -1;
#undef GetClassName
		if(strcmp(target->GetClassName(), "player") == 0)
		{
			IPlayerInfo* targetinfo = CIFaceManager::GetInstance()->GetIplayers()->GetPlayerInfo(target);
			if(targetinfo)
			{
				int ta = targetinfo->GetTeamIndex();
				int tb = playerinfo->GetTeamIndex();
				if( ta != tb )
				{
					if( targetinfo->IsPlayer() && !targetinfo->IsHLTV() && !targetinfo->IsObserver() )
					{
						return Helpers::IndexOfEdict(target);
					}
				} 
			}
		}
	}
	return -1;
}
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();
	}
}
Example #6
0
cell_t GetSurvivorScore(IPluginContext *pContext, const cell_t *params) {
	CBaseEntity *pPlayer = gamehelpers->ReferenceToEntity(params[1]);
	if (!pPlayer)
		return pContext->ThrowNativeError("Invalid client index %d", params[1]);

	cell_t client = gamehelpers->ReferenceToIndex(params[1]);

	IGamePlayer *pGamePlayer = playerhelpers->GetGamePlayer(client);
	if (!pGamePlayer || !pGamePlayer->IsInGame())
		return pContext->ThrowNativeError("Client index %d not in game", params[1]);

	IPlayerInfo* pInfo = pGamePlayer->GetPlayerInfo();
	if(!pInfo || pInfo->IsObserver() || pInfo->GetTeamIndex() != 2)
		return -1;

	return Detours::g_scores[client];
}
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();
}
Example #8
0
static cell_t GetClientTeam(IPluginContext *pContext, const cell_t *params)
{
	int client = params[1];

	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
	if (!pPlayer)
	{
		return pContext->ThrowNativeError("Client index %d is invalid", client);
	} else if (!pPlayer->IsInGame()) {
		return pContext->ThrowNativeError("Client %d is not in game", client);
	}

	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
	if (!pInfo)
	{
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
	}

	return pInfo->GetTeamIndex();
}
Example #9
0
bool CCSSBot :: isEnemy ( edict_t *pEdict,bool bCheckWeapons )
{
    if ( ENTINDEX(pEdict) > CBotGlobals::maxClients() )
        return false;
    if ( pEdict->IsFree() )
        return false;

    if ( !CBotGlobals::isNetworkable(pEdict) )
        return false;

    IPlayerInfo *p = playerinfomanager->GetPlayerInfo(pEdict);

    if ( p == NULL )
        return false;
    if ( m_pEdict == pEdict )
        return false;
    if ( !CBotGlobals::entityIsAlive ( pEdict ) )
        return false;

    return (p->GetTeamIndex() != getTeam());
}
Example #10
0
bool TF2Tools::ProcessCommandTarget(cmd_target_info_t *info)
{
	int max_clients;
	IPlayerInfo *pInfo;
	unsigned int team_index = 0;
	IGamePlayer *pPlayer, *pAdmin;

	if ((info->flags & COMMAND_FILTER_NO_MULTI) == COMMAND_FILTER_NO_MULTI)
	{
		return false;
	}

	if (info->admin)
	{
		if ((pAdmin = playerhelpers->GetGamePlayer(info->admin)) == NULL)
		{
			return false;
		}
		if (!pAdmin->IsInGame())
		{
			return false;
		}
	}
	else
	{
		pAdmin = NULL;
	}

	if (strcmp(info->pattern, "@red") == 0 )
	{
		team_index = 2;
	}
	else if (strcmp(info->pattern, "@blue") == 0)
	{
		team_index = 3;
	}
	else
	{
		return false;
	}

	info->num_targets = 0;

	max_clients = playerhelpers->GetMaxClients();
	for (int i = 1; 
		 i <= max_clients && (cell_t)info->num_targets < info->max_targets; 
		 i++)
	{
		if ((pPlayer = playerhelpers->GetGamePlayer(i)) == NULL)
		{
			continue;
		}
		if (!pPlayer->IsInGame())
		{
			continue;
		}
		if ((pInfo = pPlayer->GetPlayerInfo()) == NULL)
		{
			continue;
		}
		if (pInfo->GetTeamIndex() != (int)team_index)
		{
			continue;
		}
		if (playerhelpers->FilterCommandTarget(pAdmin, pPlayer, info->flags) 
			!= COMMAND_TARGET_VALID)
		{
			continue;
		}
		info->targets[info->num_targets] = i;
		info->num_targets++;
	}

	if (info->num_targets == 0)
	{
		info->reason = COMMAND_TARGET_EMPTY_FILTER;
	}
	else
	{
		info->reason = COMMAND_TARGET_VALID;
	}

	info->target_name_style = COMMAND_TARGETNAME_RAW;
	if (team_index == 2)
	{
		UTIL_Format(info->target_name, info->target_name_maxlength, "Red Team");
	}
	else if (team_index == 3)
	{
		UTIL_Format(info->target_name, info->target_name_maxlength, "Blue Team");
	}
	
	return true;
}
//---------------------------------------------------------------------------------
// 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;
			}
		}
	}
}
Example #12
0
bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info)
{
	IGamePlayer *pAdmin = info->admin ? playerhelpers->GetGamePlayer(info->admin) : NULL;

	if (strcmp(info->pattern, "@aim") == 0)
	{
		/* The server can't aim, of course. */
		if (pAdmin == NULL)
		{
			return false;
		}

		int player_index;
		if ((player_index = GetClientAimTarget(pAdmin->GetEdict(), true)) < 1)
		{
			info->reason = COMMAND_TARGET_NONE;
			info->num_targets = 0;
			return true;
		}

		IGamePlayer *pTarget = playerhelpers->GetGamePlayer(player_index);

		if (pTarget == NULL)
		{
			info->reason = COMMAND_TARGET_NONE;
			info->num_targets = 0;
			return true;
		}

		info->reason = playerhelpers->FilterCommandTarget(pAdmin, pTarget, info->flags);
		if (info->reason != COMMAND_TARGET_VALID)
		{
			info->num_targets = 0;
			return true;
		}

		info->targets[0] = player_index;
		info->num_targets = 1;
		info->reason = COMMAND_TARGET_VALID;
		info->target_name_style = COMMAND_TARGETNAME_RAW;
		snprintf(info->target_name, info->target_name_maxlength, "%s", pTarget->GetName());
		return true;
	}
	else if (strcmp(info->pattern, "@spec") == 0)
	{
		const char *teamname = tools_GetTeamName(1);
		if (strcasecmp(teamname, "spectator") != 0)
			return false;
		info->num_targets = 0;
		for (int i = 1; i <= playerhelpers->GetMaxClients(); i++)
		{
			IGamePlayer *player = playerhelpers->GetGamePlayer(i);
			if (player == NULL || !player->IsInGame())
				continue;
			IPlayerInfo *plinfo = player->GetPlayerInfo();
			if (plinfo == NULL)
				continue;
			if (plinfo->GetTeamIndex() == 1 &&
			    playerhelpers->FilterCommandTarget(pAdmin, player, info->flags) ==
				COMMAND_TARGET_VALID)
			{
				info->targets[info->num_targets++] = i;
			}
		}
		info->reason = info->num_targets > 0 ? COMMAND_TARGET_VALID : COMMAND_TARGET_EMPTY_FILTER;
		info->target_name_style = COMMAND_TARGETNAME_ML;
		snprintf(info->target_name, info->target_name_maxlength, "all spectators");
		return true;
	}

	return false;
}
Example #13
0
//=================================================================================
// Callback for the 'webspec' protocol
// Manages spectator connections & sending Initial messages to new spectators
//=================================================================================
int webspec_callback(struct libwebsocket_context *ctx, struct libwebsocket *wsi, 
	enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len)
{
	switch (reason) {
		case LWS_CALLBACK_ESTABLISHED:
		{
			Msg("[WS] New connection\n");
			// New connection
			ws_spectators.AddToTail(wsi);
			
			// Send basic game info to let client set up
			// MapName, Server name (may remove), current team names
			char *buffer = (char*)malloc(MAX_BUFFER_SIZE);
			char *mapName = (char*) STRING(gpGlobals->mapname);
			ConVarRef hostNameCVar = ConVarRef("hostname");
			string_t hostname;
			if (hostNameCVar.IsValid())
				hostname = MAKE_STRING(hostNameCVar.GetString());
			else
				hostname = MAKE_STRING("WebSpec Demo Server"); //Can't imagine when hostname would be invalid, but this is Source
			int length = snprintf(buffer, MAX_BUFFER_SIZE, "%c%s:%s:%s:%s", WSPacket_Init, mapName, STRING(hostname), STRING(ws_teamName[1]), STRING(ws_teamName[0]));

			SendPacketToOne(buffer, length, wsi);
			free(buffer);

			//Send connected players
			IPlayerInfo *playerInfo;
			for (int i=1; i<=gpGlobals->maxClients; i++) {
				playerInfo = playerInfoManager->GetPlayerInfo(engine->PEntityOfEntIndex(i));
				if (playerInfo != NULL && playerInfo->IsConnected()) {
					buffer = (char *)malloc(MAX_BUFFER_SIZE);
					int userid = playerInfo->GetUserID();
					int teamid = playerInfo->GetTeamIndex();
					int health = playerInfo->GetHealth();
					int maxHealth = playerInfo->GetMaxHealth();
					bool alive = !playerInfo->IsDead();
					string_t playerName = MAKE_STRING(playerInfo->GetName());
					
					//Pointer magic to get TF2 class
					CBaseEntity *playerEntity = serverGameEnts->EdictToBaseEntity(engine->PEntityOfEntIndex(i));
					int playerClass = *MakePtr(int*, playerEntity, WSOffsets::pCTFPlayer__m_iClass);

					float uberCharge = 0.0f;
					
					if (playerClass == TFClass_Medic) { 
						//Way more pointer magic to get ubercharge from medigun
						CBaseCombatCharacter *playerCombatCharacter = CBaseEntity_MyCombatCharacterPointer(playerEntity);
						CBaseCombatWeapon *slot1Weapon = CBaseCombatCharacter_Weapon_GetSlot(playerCombatCharacter, 1);
						
						uberCharge = *MakePtr(float*, slot1Weapon, WSOffsets::pCWeaponMedigun__m_flChargeLevel);
					}

					int length = snprintf(buffer, MAX_BUFFER_SIZE, "%c%d:%d:%d:%d:%d:%d:0:%d:%s", 'C', userid, teamid, playerClass,
						health, maxHealth, alive, Round(uberCharge*100.0f), STRING(playerName));

					SendPacketToOne(buffer, length, wsi);
					free(buffer);
				}
			}

			break;
		}
Example #14
0
void CFlagEvent::Execute(IBotEventInterface *pEvent)
{
	// dropped / picked up ID
	int type = pEvent->GetInt("eventtype");
	// player id
	int player = pEvent->GetInt("player");

	edict_t *pPlayer = NULL;
	CBot *pBot = NULL;

	// Crash fix
	if (player)
	{
		pPlayer = INDEXENT(player);
		pBot = CBots::GetBotPointer(pPlayer);
	}

	switch (type)
	{
	case FLAG_PICKUP: // pickup
		if (pBot && pBot->IsTF())
		{
			((CBotTF2*)pBot)->PickedUpFlag();
		}

		if (pPlayer)
		{
			int iTeam = CTeamFortress2Mod::GetTeam(pPlayer);

			if (CTeamFortress2Mod::IsFlagAtDefaultState())
			{
				CClient *pClient;

				pClient = CClients::Get(pPlayer);

				if (pClient && pClient->AutoWaypointOn())
					pClient->AutoEventWaypoint(CWaypointTypes::W_FL_FLAG, 200.0f, false);
			}

			CTeamFortress2Mod::FlagPickedUp(iTeam, pPlayer);

		}


		break;
	case FLAG_CAPTURED: // captured
	{
		IPlayerInfo *p = NULL;

		if (pPlayer)
		{
			p = playerinfomanager->GetPlayerInfo(pPlayer);

			if (p)
			{
				CBroadcastFlagCaptured captured = CBroadcastFlagCaptured(p->GetTeamIndex());
				CBots::BotFunction(&captured);
			}
		}

		if (pBot && pBot->IsTF())
		{
			((CBotTF2*)pBot)->CapturedFlag();
			((CBotTF2*)pBot)->DroppedFlag();
		}

		if (pPlayer)
		{
			int iTeam = CTeamFortress2Mod::GetTeam(pPlayer);
			CTeamFortress2Mod::FlagDropped(iTeam, Vector(0, 0, 0));

			CClient *pClient;

			pClient = CClients::Get(pPlayer);

			if (pClient && pClient->AutoWaypointOn())
				pClient->AutoEventWaypoint(CWaypointTypes::W_FL_CAPPOINT, 200.0f, false);
		}

		CTeamFortress2Mod::ResetFlagStateToDefault();

	}
	break;
	case FLAG_DROPPED: // drop
	{
		IPlayerInfo *p = playerinfomanager->GetPlayerInfo(pPlayer);
		Vector vLoc;

		if (p)
		{
			vLoc = CBotGlobals::EntityOrigin(pPlayer);
			CBroadcastFlagDropped dropped = CBroadcastFlagDropped(p->GetTeamIndex(), vLoc);
			CBots::BotFunction(&dropped);
		}

		if (pBot && pBot->IsTF())
			((CBotTF2*)pBot)->DroppedFlag();


		if (pPlayer)
			CTeamFortress2Mod::FlagDropped(CTeamFortress2Mod::GetTeam(pPlayer), vLoc);
	}
	break;
	case FLAG_RETURN:
	{
		if (CTeamFortress2Mod::IsMapType(TF_MAP_SD))
		{
			CBroadcastFlagReturned returned = CBroadcastFlagReturned(CTeamFortress2Mod::GetFlagCarrierTeam());
			CBots::BotFunction(&returned);
		}
		CTeamFortress2Mod::ResetFlagStateToDefault();

		CTeamFortress2Mod::FlagReturned(0); // for special delivery
		//p->GetTeamIndex(),CBotGlobals::EntityOrigin(pPlayer));
	}
	break;
	default:
		break;
	}

}