//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CAI_Expresser::SpeechMsg( CBaseEntity *pFlex, const char *pszFormat, ... )
{
	if ( !DebuggingSpeech() )
		return;

	if ( pFlex->MyNPCPointer() )
	{
		DevMsg( pFlex->MyNPCPointer(), CFmtStr( &pszFormat ) );
	}
	else 
	{
		DevMsg( CFmtStr( &pszFormat ) );
	}
	UTIL_LogPrintf( (char *) ( (const char *) CFmtStr( &pszFormat ) ) );
}
// sets the length of the pause between round end and respawning
void CBaseRoundRules::SetRestartLength(float flRestartTime)
{
	if(flRestartTime > GetRestartTimeLimit()) {
		flRestartTime = GetRestartTimeLimit();
	}

	if(flRestartTime >= 0) {
		m_flRestartTime = gpGlobals->time + flRestartTime;
	} else {
		// -- this is wierd to log it
		ALERT(at_console, "Bad Restart Length being set - (%1.f)\n", flRestartTime);
		UTIL_LogPrintf(ROUND_LOGGING, "World triggered \"Bad Restart Length\" (restart_length \"%1.f\") (old_restart_length \"1.f\") (respawn_style \"%i\") (round_state \"%i\")\n", flRestartTime, GetRestartTime(), (int)m_iRespawnStyle, (int)m_iRoundState);
		
		m_flRestartTime = gpGlobals->time + GetRestartTimeLimit();
	}
}
// returns the current round state
ROUND_STATE CBaseRoundRules::GetRoundState()
{
	// check validity of current round state
	if(!m_iRoundState)
	{
		// - report the error
		ALERT(at_console, "Null Round State\n");
		UTIL_LogPrintf(ROUND_LOGGING, "World triggered \"Null Round State\"\n");

		// - set a default round state to help the game recover
		SetRoundState(ROUND_NOTSTARTED, false);
		return m_iRoundState;
	}

	return m_iRoundState;
}
示例#4
0
//=========================================================
//=========================================================
void CHalfLifeMultiplay :: ClientDisconnected( edict_t *pClient )
{
	if ( pClient )
	{
		CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance( pClient );
		
		if ( pPlayer )
		{
			FireTargets( "game_playerleave", pPlayer, pPlayer, USE_TOGGLE, 0 );
			
			UTIL_LogPrintf( "%s disconnected\n", GetLogStringForPlayer( pPlayer->edict() ).c_str() );
			
			pPlayer->RemoveAllItems( TRUE );// destroy all of the players weapons and items
		}
	}
}
示例#5
0
void FuncPrintfLog(const char *str, ...)
{
	va_list			argptr;
	static char		string[1024];

	va_start(argptr, str);
	vsnprintf(string, sizeof(string), str, argptr);
	va_end(argptr);

	FILE *file = NULL;
	int length;
	const char *path = "AdminMod/logs/";
	char fullpath[PATH_MAX];
	char line[MAX_CONF_LEN];

	time_t clock = time(NULL);
	tm *ltm = localtime(&clock);

	sup_gamedir_path(path, fullpath);

	sup_make_str(fullpath + strlen(fullpath), sizeof(fullpath), "%d-%d-%d_1.txt", ltm->tm_mday, ltm->tm_mon + 1,
		1900 + ltm->tm_year);
	sup_make_str(line, sizeof(line), "[%d-%d-%d] - [%d:%d:%d] : %s\n", ltm->tm_mday, ltm->tm_mon + 1,
		1900 + ltm->tm_year, ltm->tm_hour, ltm->tm_min, ltm->tm_sec, string);

	while(1)
	{
		file = fopen(fullpath, "a+");
		if(!file)
		{
			UTIL_LogPrintf("Unable to create log list file '%s': %s", fullpath, strerror(errno));
			return;
		}

		fseek(file, 0, SEEK_END);
		length = ftell(file);

		if(length >= MAX_FILE_LEN)
			sup_add_symb(fullpath, strlen(fullpath) - 5);
		else break;

		fclose(file);
	}

	fputs(line, file);
	fclose(file);
}
//=========================================================
// 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->m_szTeamName ) )
		return;

	if ( defaultteam.value )
	{
		int clientIndex = pPlayer->entindex();

		g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->m_szTeamName );
		g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->m_szTeamName );
		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->m_szTeamName );
		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() ),
		GETPLAYERAUTHID( pPlayer->edict() ),
		pPlayer->m_szTeamName,
		mdls );

	ChangePlayerTeam( pPlayer, mdls, TRUE, TRUE );
	// recound stuff
	RecountTeams( TRUE );
}
// setup all variables up to default state
CBaseRoundRules::CBaseRoundRules()
{
	m_flRoundTimeLimit = 0.0;
	m_flRoundTime = 0.0;

	m_iRespawnStyle = NULL_RESPAWN;
	SetRespawnStyle((RESPAWN_STYLE)((int)CVAR_GET_FLOAT("mp_respawnstyle")));

	m_iRoundState = ROUND_NOTSTARTED;

	iCount = 0;
	ClearTeamsCount();
	m_iWinningTeam = 0;

	ALERT(at_console, "New Round Rules Created\n");
	UTIL_LogPrintf(ROUND_LOGGING, "World triggered \"Round Rules Created\"\n");
}
示例#8
0
文件: NBase.cpp 项目: Chuvi-w/amxmodx
/* 
0 [Byte]	1	// Weapons Groupings
1 [Byte]	210	// Total Rounds Allowed
2 [Byte]	-1	// Undefined Not Used
3 [Byte]	-1	// Undefined Not Used
4 [Byte]	2	// Weapon Slot
5 [Byte]	0	// Bucket ( Position Under Weapon Slot )
6 [Short]	7	// Weapon Number / Bit Field for the weapon
7 [Byte]	128	// Bit Field for the Ammo or Ammo Type
8 [Byte]	30	// Rounds Per Mag

id, wpnID, slot, position, totalrds
*/
static cell AMX_NATIVE_CALL dod_weaponlist(AMX *amx, cell *params) // player
{
	if(!weaponlist[params[1]].changeable)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "This Weapon Cannot be Changed");
		return 0;
	}

	int id = params[1];
	int wpnID = params[2];
	int slot = params[3];
	int position = params[4];
	int totalrds = params[5];

	UTIL_LogPrintf("ID (%d) WpnID (%d) Slot (%d) Pos (%d) Rounds (%d)", id, wpnID, slot, position, totalrds);

	CHECK_PLAYER(id);

	CPlayer* pPlayer = GET_PLAYER_POINTER_I(id);
	if(!pPlayer->ingame)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid Player, Not on Server");
		return 0;
	}
	
	MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "WeaponList", NULL), NULL, INDEXENT(id));
	WRITE_BYTE(weaponlist[wpnID].grp);
		WRITE_BYTE(totalrds);
		WRITE_BYTE(-1);
		WRITE_BYTE(-1);
		WRITE_BYTE(slot - 1);
		WRITE_BYTE(position);
		WRITE_SHORT(wpnID);
		WRITE_BYTE(weaponlist[wpnID].bitfield);

		// Is it grenades
		if(wpnID == 13 || wpnID == 14 || wpnID == 15 || wpnID == 16 || wpnID == 36)
			WRITE_BYTE(-1);
		else if(wpnID == 29 || wpnID == 30 || wpnID == 31)
			WRITE_BYTE(1);
		else
			WRITE_BYTE(weaponlist[wpnID].clip);
	MESSAGE_END();

	return 1;
}
示例#9
0
//=========================================================
//=========================================================
void CHalfLifeMultiplay :: ClientDisconnected( edict_t *pClient )
{
	if ( pClient )
	{
		CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance( pClient );

		if ( pPlayer )
		{
			FireTargets( "game_playerleave", pPlayer, pPlayer, USE_TOGGLE, 0 );

			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" disconnected\n",  
				STRING( pPlayer->pev->netname ), 
				GETPLAYERUSERID( pPlayer->edict() ),
				GETPLAYERAUTHID( pPlayer->edict() ),
				GETPLAYERUSERID( pPlayer->edict() ) );

			pPlayer->RemoveAllItems( TRUE );// destroy all of the players weapons and items

			// Tell all clients this player isn't a spectator anymore
			MESSAGE_BEGIN( MSG_ALL, gmsgSpectator );  
				WRITE_BYTE( ENTINDEX(pClient) );
				WRITE_BYTE( 0 );
			MESSAGE_END();

			CBasePlayer *client = NULL;
			while ( ((client = (CBasePlayer*)UTIL_FindEntityByClassname( client, "player" )) != NULL) && (!FNullEnt(client->edict())) ) 
			{
				if ( !client->pev )
					continue;
				if ( client == pPlayer )
					continue;

				// If a spectator was chasing this player, move him/her onto the next player
				if ( client->m_hObserverTarget == pPlayer )
				{
					int iMode = client->pev->iuser1;
					client->pev->iuser1 = 0;
					client->m_hObserverTarget = NULL;
					client->Observer_SetMode( iMode );
				}
			}
		}
	}
}
//=========================================================
// 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();
}
示例#11
0
//=========================================================
//=========================================================
void CHalfLifeRules :: ClientDisconnected( edict_t *pClient )
{
	if ( pClient )
	{
		CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance( pClient );

		if ( pPlayer )
		{
			FireTargets( "game_playerleave", pPlayer, pPlayer, USE_TOGGLE, 0 );

			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" disconnected\n",  
			STRING( pPlayer->pev->netname ), 
			GETPLAYERUSERID( pPlayer->edict() ),
			GETPLAYERAUTHID( pPlayer->edict() ),
			GETPLAYERUSERID( pPlayer->edict() ) );

			pPlayer->RemoveAllItems( TRUE );// destroy all of the players weapons and items
		}
	}
}
示例#12
0
/*
========================
ClientUserInfoChanged

called after the player changes
userinfo - gives dll a chance to modify it before
it gets sent into the rest of the engine.
========================
*/
void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer )
{
	// Is the client spawned yet?
	if ( !pEntity->pvPrivateData )
		return;

	// msg everyone if someone changes their name,  and it isn't the first time (changing no name to current name)
	if ( pEntity->v.netname && STRING(pEntity->v.netname)[0] != 0 && !FStrEq( STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" )) )
	{
		char text[256];
		sprintf( text, "* %s changed name to %s\n", STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
		MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
			WRITE_BYTE( ENTINDEX(pEntity) );
			WRITE_STRING( text );
		MESSAGE_END();

		UTIL_LogPrintf( "\"%s<%i>\" changed name to \"%s<%i>\"\n", STRING( pEntity->v.netname ), GETPLAYERUSERID( pEntity ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ), GETPLAYERUSERID( pEntity ) );
	}

	g_pGameRules->ClientUserInfoChanged( GetClassPtr((CBasePlayer *)&pEntity->v), infobuffer );
}
void AvHVisibleBlipList::AddBlip(float inX, float inY, float inZ, int8 inStatus, int8 inBlipInfo)
{
	//ASSERT(this->mNumBlips < kMaxBlips);
	if(this->mNumBlips < (kMaxBlips-1))
	{
		int theBlipOffset = this->mNumBlips;
		
		this->mBlipPositions[theBlipOffset][0] = inX;
		this->mBlipPositions[theBlipOffset][1] = inY;
		this->mBlipPositions[theBlipOffset][2] = inZ;
		this->mBlipStatus[theBlipOffset] = inStatus;
		this->mBlipInfo[theBlipOffset] = inBlipInfo;
		
		this->mNumBlips++;
	}
	else
	{
		#ifdef AVH_SERVER
		UTIL_LogPrintf("AvHVisibleBlipList::AddBlip(%f, %f, %f, status: %d):  Can't add blip, max limit %d reached.\n", inX, inY, inZ, inStatus, kMaxBlips);
		#endif
	}
}
示例#14
0
void CHostage::AnnounceDeath(CBasePlayer *pAttacker)
{
	ClientPrint(pAttacker->pev, HUD_PRINTCENTER, "#Killed_Hostage");

	if (!(pAttacker->m_flDisplayHistory & DHF_HOSTAGE_KILLED))
	{
		pAttacker->HintMessage("#Hint_lost_money");
		pAttacker->m_flDisplayHistory |= DHF_HOSTAGE_KILLED;
	}

	if (!g_pGameRules->IsMultiplayer())
		CHalfLifeTraining::HostageDied();

	UTIL_LogPrintf("\"%s<%i><%s><%s>\" triggered \"Killed_A_Hostage\"\n", STRING(pAttacker->pev->netname), GETPLAYERUSERID(pAttacker->edict()), GETPLAYERAUTHID(pAttacker->edict()), GetTeam(pAttacker->m_iTeam));

	MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
	WRITE_BYTE(9);
	WRITE_BYTE(DRC_CMD_EVENT);
	WRITE_SHORT(ENTINDEX(pAttacker->edict()));
	WRITE_SHORT(ENTINDEX(edict()));
	WRITE_LONG(15);
	MESSAGE_END();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamRoundTimer::RoundTimerSetupThink( void )
{
	if ( TeamplayRoundBasedRules()->IsInPreMatch() == true && IsDisabled() == false )
	{
		inputdata_t data;
		InputDisable( data );
		m_OnSetupFinished.FireOutput( this, this );
	}

	if ( IsDisabled() || m_bTimerPaused )
	{
		SetContextThink( &CTeamRoundTimer::RoundTimerSetupThink, gpGlobals->curtime + 0.05, ROUND_TIMER_SETUP_THINK );
		return;
	}

	float flTime = GetTimeRemaining();
	TeamplayRoundBasedRules()->SetOvertime( false );

	if ( flTime <= 0.0f && m_bFireFinished )
	{
		IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_setup_finished" );
		if ( event )
		{
			gameeventmanager->FireEvent( event );
		}

		m_OnSetupFinished.FireOutput( this, this );
		m_bFireFinished = false;

		SetTimeRemaining( m_nTimeToUseAfterSetupFinished );
		SetState( RT_STATE_NORMAL );

		if ( ShowInHud() && !TeamplayRoundBasedRules()->IsInWaitingForPlayers() )
		{
			UTIL_LogPrintf( "World triggered \"Round_Setup_End\"\n" );
		}
		return;
	}
	else if ( flTime <= 60.0 && m_bFire1MinRemain )
	{
		m_On1MinRemain.FireOutput( this, this );
		m_bFire1MinRemain = false;
	}
	else if ( flTime <= 30.0 && m_bFire30SecRemain )
	{
		m_On30SecRemain.FireOutput( this, this );
		m_bFire30SecRemain = false;
	}
	else if ( flTime <= 10.0 && m_bFire10SecRemain )
	{
		m_On10SecRemain.FireOutput( this, this );
		m_bFire10SecRemain = false;
	}
	else if ( flTime <= 5.0 && m_bFire5SecRemain )
	{
		m_On5SecRemain.FireOutput( this, this );
		m_bFire5SecRemain = false;
	}
	else if ( flTime <= 4.0 && m_bFire4SecRemain )
	{
		m_On4SecRemain.FireOutput( this, this );
		m_bFire4SecRemain = false;
	}
	else if ( flTime <= 3.0 && m_bFire3SecRemain )
	{
		m_On3SecRemain.FireOutput( this, this );
		m_bFire3SecRemain = false;
	}
	else if ( flTime <= 2.0 && m_bFire2SecRemain )
	{
		m_On2SecRemain.FireOutput( this, this );
		m_bFire2SecRemain = false;
	}
	else if ( flTime <= 1.0 && m_bFire1SecRemain )
	{
		m_On1SecRemain.FireOutput( this, this );
		m_bFire1SecRemain = false;
	}

	SetContextThink( &CTeamRoundTimer::RoundTimerSetupThink, gpGlobals->curtime + 0.05, ROUND_TIMER_SETUP_THINK );
}
示例#16
0
//=========================================================
// Deathnotice. 
//=========================================================
void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor )
{
	// Work out what killed the player, and send a message to all clients about it
	CBaseEntity *Killer = CBaseEntity::Instance( pKiller );

	const char *killer_weapon_name = "world";		// by default, the player is killed by the world
	int killer_index = 0;
	
	// Hack to fix name change
	char *tau = "tau_cannon";
	char *gluon = "gluon gun";

	// QUAKECLASSIC
	// Might have overridden
	if (g_szDeathType)
	{
		killer_weapon_name = g_szDeathType;
	}
	else
	{
		if ( pKiller->flags & FL_CLIENT )
		{
			killer_index = ENTINDEX(ENT(pKiller));
			
			if ( pevInflictor )
			{
				if ( pevInflictor == pKiller )
				{
					// If the inflictor is the killer,  then it must be their current weapon doing the damage
					CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pKiller );
					
					switch( pPlayer->m_iQuakeWeapon )
					{
						case IT_AXE: killer_weapon_name = "weapon_axe"; break;
						case IT_SHOTGUN: killer_weapon_name = "weapon_shotgun"; break;
						case IT_SUPER_SHOTGUN: killer_weapon_name = "weapon_doubleshotgun"; break;
						case IT_NAILGUN: killer_weapon_name = "weapon_nailgun"; break;
						case IT_SUPER_NAILGUN: killer_weapon_name = "weapon_supernail"; break;
						case IT_GRENADE_LAUNCHER: killer_weapon_name = "weapon_grenadel"; break;
						case IT_ROCKET_LAUNCHER: killer_weapon_name = "weapon_rocketl"; break;
						case IT_LIGHTNING: killer_weapon_name = "weapon_lightning"; break;
							
						default:
							killer_weapon_name = "Empty";
					} 
				
				}
				else
				{
					killer_weapon_name = STRING( pevInflictor->classname );  // it's just that easy
				}
			}
		}
		else
		{
			killer_weapon_name = STRING( pevInflictor->classname );
		}

		// strip the monster_* or weapon_* from the inflictor's classname
		if ( strncmp( killer_weapon_name, "weapon_", 7 ) == 0 )
			killer_weapon_name += 7;
		else if ( strncmp( killer_weapon_name, "monster_", 8 ) == 0 )
			killer_weapon_name += 8;
		else if ( strncmp( killer_weapon_name, "func_", 5 ) == 0 )
			killer_weapon_name += 5;
	}

	MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
		WRITE_BYTE( killer_index );						// the killer
		WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
		WRITE_STRING( killer_weapon_name );		// what they were killed by (should this be a string?)
	MESSAGE_END();

	// replace the code names with the 'real' names
	if ( !strcmp( killer_weapon_name, "egon" ) )
		killer_weapon_name = gluon;
	else if ( !strcmp( killer_weapon_name, "gauss" ) )
		killer_weapon_name = tau;

	if ( pVictim->pev == pKiller )  
	{  
		// killed self
#if !defined( THREEWAVE )
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"%s\"\n",  
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ),
			GETPLAYERAUTHID( pVictim->edict() ),
			GETPLAYERUSERID( pVictim->edict() ),
			killer_weapon_name );		
#else
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\"\n",  
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ),
			GETPLAYERAUTHID( pVictim->edict() ),
			GetTeamName( pVictim->pev->team ),
			killer_weapon_name );		
#endif
	}
	else if ( pKiller->flags & FL_CLIENT )
	{
#if !defined( THREEWAVE )
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" killed \"%s<%i><%s><%i>\" with \"%s\"\n",  
			STRING( pKiller->netname ),
			GETPLAYERUSERID( ENT(pKiller) ),
			GETPLAYERAUTHID( ENT(pKiller) ),
			GETPLAYERUSERID( ENT(pKiller) ),
			STRING( pVictim->pev->netname ),
			GETPLAYERUSERID( pVictim->edict() ),
			GETPLAYERAUTHID( pVictim->edict() ),
			GETPLAYERUSERID( pVictim->edict() ),
			killer_weapon_name );
#else
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" killed \"%s<%i><%s><%s>\" with \"%s\"\n",  
			STRING( pKiller->netname ),
			GETPLAYERUSERID( ENT(pKiller) ),
			GETPLAYERAUTHID( ENT(pKiller) ),
			GetTeamName( pKiller->team ),
			STRING( pVictim->pev->netname ),
			GETPLAYERUSERID( pVictim->edict() ),
			GETPLAYERAUTHID( pVictim->edict() ),
			GetTeamName( pVictim->pev->team ),
			killer_weapon_name );
#endif
	}
	else
	{  
		// killed by the world
#if !defined( THREEWAVE )
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"%s\" (world)\n",
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ), 
			GETPLAYERAUTHID( pVictim->edict() ),
			GETPLAYERUSERID( pVictim->edict() ),
			killer_weapon_name );				
#else
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\" (world)\n",
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ), 
			GETPLAYERAUTHID( pVictim->edict() ),
			GetTeamName( pVictim->pev->team ),
			killer_weapon_name );				
#endif
	}

	g_szDeathType = NULL;

	// HLTV event msg
	MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR );
		WRITE_BYTE ( 9 );	// command length in bytes
		WRITE_BYTE ( DRC_CMD_EVENT );	// player killed
		WRITE_SHORT( ENTINDEX(pVictim->edict()) );	// index number of primary entity
		if (pevInflictor)
			WRITE_SHORT( ENTINDEX(ENT(pevInflictor)) );	// index number of secondary entity
		else
			WRITE_SHORT( ENTINDEX(ENT(pKiller)) );	// index number of secondary entity
		WRITE_LONG( 7 | DRC_FLAG_DRAMATIC);   // eventflags (priority and flags)
	MESSAGE_END();

//  Print a standard message
	// TODO: make this go direct to console
	return; // just remove for now

}
示例#17
0
/* <1ef79d> ../cstrike/dlls/career_tasks.cpp:385 */
void CCareerTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pVictim, CBasePlayer *pAttacker)
{
	if (m_isComplete)
		return;

	if (event == m_event)
	{
		if ((m_defuser && !pAttacker->m_bIsDefusing) || (m_vip && !pAttacker->m_bIsVIP))
			return;

		if (m_rescuer)
		{
			int hostages_ = 0;
			CBaseEntity *hostageEntity = NULL;

			while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL)
			{
				if (hostageEntity->pev->takedamage != DAMAGE_YES)
					continue;

				CHostage *hostage = static_cast<CHostage *>(hostageEntity);

				if (!hostage->IsFollowingSomeone())
					continue;

				if (hostage->IsValid() && hostage->m_target == pAttacker)
					++hostages_;
			}

			if (!hostages_)
			{
				return;
			}
		}

		if (m_event != EVENT_KILL || (!m_weaponId && !m_weaponClassId)
			&& m_event != EVENT_HEADSHOT || (!m_weaponId && !m_weaponClassId)
			&& m_event != EVENT_PLAYER_TOOK_DAMAGE || (!m_weaponId && !m_weaponClassId))
		{
			if (m_event == EVENT_ROUND_WIN)
			{
				if (!Q_strcmp(m_name, "defendhostages"))
				{
					int hostages_ = 0;
					CBaseEntity *hostageEntity = NULL;

					while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL)
					{
						if (hostageEntity->pev->takedamage != 1.0f && hostageEntity->pev->deadflag != DEAD_DEAD)
							++hostages_;
					}

					if (!hostages_)
					{
						++m_eventsSeen;
						SendPartialNotification();
					}
				}
				else if (!Q_strcmp(m_name, "hostagessurvive"))
				{
					int hostages_ = 0;
					CBaseEntity *hostageEntity = NULL;

					while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL)
					{
						CHostage *hostage = (CHostage *)hostageEntity;

						if (hostage && hostage->IsDead())
							++hostages_;
					}

					if (!hostages_)
					{
						++m_eventsSeen;
						SendPartialNotification();
					}
				}
				else if (!Q_strcmp(m_name, "winfast"))
				{
					if (m_eventsNeeded >= TheCareerTasks->GetRoundElapsedTime())
					{
						m_eventsSeen = m_eventsNeeded;
						SendPartialNotification();
					}
				}
				else if (IsTaskCompletableThisRound())
				{
					++m_eventsSeen;
					SendPartialNotification();
				}
			}
			else
			{
				++m_eventsSeen;
				SendPartialNotification();
			}
		}
	}

	if (event == m_event && !m_mustLive && m_eventsSeen >= m_eventsNeeded && IsTaskCompletableThisRound())
	{
		CBasePlayer *player = UTIL_GetLocalPlayer();
		EMIT_SOUND(ENT(player->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM);

		m_isComplete = true;
		MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer);
			WRITE_STRING("TASKDONE");
			WRITE_BYTE(m_id);
		MESSAGE_END();

		if (TheTutor != NULL)
		{
			TheTutor->OnEvent(EVENT_CAREER_TASK_DONE);
		}

		UTIL_LogPrintf("Career Task Done %d\n", m_id);

		if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast"))
		{
			TheCareerTasks->SetFinishedTaskTime((int)TheCareerTasks->GetRoundElapsedTime());
			UTIL_GetLocalPlayer()->SyncRoundTimer();
		}
	}
	else if (event >= EVENT_ROUND_DRAW)
	{
		if (event > EVENT_ROUND_LOSS)
		{
			if (event == EVENT_DIE && (m_mustLive || m_crossRounds))
			{
				m_eventsSeen = 0;
				SendPartialNotification();
				m_diedThisRound = true;
			}
		}
		else if (m_mustLive)
		{
			if (m_eventsSeen >= m_eventsNeeded && !m_diedThisRound && IsTaskCompletableThisRound())
			{
				CBasePlayer *player = UTIL_GetLocalPlayer();
				EMIT_SOUND(ENT(player->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM);

				m_isComplete = true;
				MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer);
					WRITE_STRING("TASKDONE");
					WRITE_BYTE(m_id);
				MESSAGE_END();

				UTIL_LogPrintf("Career Task Done %d\n", m_id);

				if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast"))
				{
					TheCareerTasks->SetFinishedTaskTime((int)TheCareerTasks->GetRoundElapsedTime());
					UTIL_GetLocalPlayer()->SyncRoundTimer();
				}

				if (TheTutor != NULL)
				{
					TheTutor->OnEvent(EVENT_CAREER_TASK_DONE);
				}
			}

			m_diedThisRound = false;

			if (m_mustLive)
			{
				m_eventsSeen = 0;
				SendPartialNotification();
			}
		}
	}
}
示例#18
0
bool FuncIsBanned(const char *name, int &minutes)
{
	FILE *file = NULL;
	const char *path = "AdminMod/banned.txt";
	char fullpath[PATH_MAX];
	char line[MAX_CONF_LEN];
	char *banned = NULL, *date = NULL, *cur = NULL;

	time_t clock = time(NULL);
	tm *ltm = localtime(&clock);

	sup_gamedir_path(path, fullpath);
	LOG_CONSOLE(NULL, "path - %s", fullpath);

	file = fopen(fullpath, "r");
	if(!file)
	{
		UTIL_LogPrintf("Unable to open banned list file '%s': %s", fullpath, strerror(errno));
		return false;
	}

	for(int i = 1, j = 0; !feof(file); i++)
	{
		if(!fgets(line, sizeof(line), file))
		{
			UTIL_LogPrintf("Unable to read %d line in file %s", i, fullpath);
			fclose(file);
			return false;
		}

		if(line[0] == '#' || line[0] == ';')
			continue;
		if(strnmatch(line, "//", 2))
			continue;

		j = strlen(line) - 1;
		if(line[j] == '\n')
			line[j] = '\0';

		banned = strtok(line, "\"");
		if(!banned)
		{
			UTIL_LogPrintf("Invalid parameters at line %d in file %s", i, fullpath);
			fclose(file);
			return false;
		}
		sup_del_quotes(banned);

		if(strcmp(banned, name) == 0)
		{
			minutes = 0;
			date = strtok(NULL, "\n");
			for(USHORT k = 0; k < strlen(date); k++)
				if(date[k] != ' ' && date[k] != '\t')
				{
					STRNCPY(date, date + k, strlen(date));
					break;
				}
			if(date[0] == '-')
			{
				fclose(file);
				return true;
			}

			cur = strtok(date, ":");
			minutes += sup_str_to_int(cur) - ltm->tm_min;
			cur = strtok(NULL, " ");
			minutes += 60 * (sup_str_to_int(cur) - ltm->tm_hour);
			cur = strtok(NULL, ":");
			minutes += 60 * 24 * (sup_str_to_int(cur) - ltm->tm_yday);
			cur = strtok(NULL, ":");
			minutes += 60 * 24 * 30 * (sup_str_to_int(cur) - ltm->tm_year);

			fclose(file);
			if(minutes <= 0)
			{
				FuncRemoveFromBanned(banned);
				return false;
			}
			else return true;
		}
	}

	fclose(file);
	return false;
}
示例#19
0
bool FuncRemoveFromBanned(const char *name)
{
	FILE *file = NULL;
	const char *path = "AdminMod/banned.txt";
	char fullpath[PATH_MAX];
	char line[MAX_CONF_LEN];
	char *banned = NULL;
	int offset = 0, cur = 0;

	sup_gamedir_path(path, fullpath);

	file = fopen(fullpath, "r+");
	if(!file)
	{
		UTIL_LogPrintf("Unable to open banned list file '%s': %s", fullpath, strerror(errno));
		return false;
	}

	for(int i = 1, j = 0; !feof(file); i++)
	{
		if(!fgets(line, sizeof(line), file))
		{
			UTIL_LogPrintf("Unable to read %d line in file %s", i, fullpath);
			fclose(file);
			return false;
		}

		if(line[0] == '#' || line[0] == ';')
			continue;
		if(strnmatch(line, "//", 2))
			continue;

		j = strlen(line) - 1;
		if(line[j] == '\n')
			line[j] = '\0';

		offset = strlen(line);
		banned = strtok(line, "\"");
		if(!banned)
		{
			UTIL_LogPrintf("Invalid parameters at line %d in file %s", i, fullpath);
			fclose(file);
			return false;
		}
		sup_del_quotes(banned);

		LOG_CONSOLE(NULL, "banned - %s; list name - %s", banned, name);
		if(strcmp(banned, name) == 0)
		{
			LOG_CONSOLE(NULL, "size of offset - %d", offset);

			while(1)
			{
				if(fgets(line, sizeof(line), file) == NULL)
				{
					fseek(file, -(offset + 3), SEEK_CUR);
					fputs("\n", file);
					chsize(fileno(file), ftell(file));
					fclose(file);
					return true;
				}
				if(feof(file))
					break;
				LOG_CONSOLE(NULL, "read line - %s", line);
				cur = strlen(line);
				fseek(file, -(cur + offset + 3), SEEK_CUR);
				fputs(line, file);
				fseek(file, offset + 2, SEEK_CUR);
			}

			LOG_CONSOLE(NULL, "read line - %s", line);
			cur = strlen(line);
			fseek(file, -(cur + offset + 2), SEEK_CUR);
			fputs(line, file);
			chsize(fileno(file), ftell(file));
			break;
		}
	}

	fclose(file);
	return true;
}
示例#20
0
void CGrenade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
    int barTime;

    if( !m_fPlantedC4 )
    {
        return;
    }

    CBasePlayer* pPlayer = GetClassPtr( (CBasePlayer *)pActivator->pev );

    if( pPlayer->m_iTeam == TEAM_CT )
    {
        if( m_fStartDefuse )
        {
            m_flNextDefuseTime = gpGlobals->time + 0.5;
            return;
        }

        SET_CLIENT_MAXSPEED( ENT( pPlayer->pev ), 1.0 );

        // TODO: Adds support for bots.
        // TheBots->OnEvent( EVENT_BOMB_DEFUSING, pActivator, NULL );

        if( g_pGameRules->IsCareer() )
        {
            // TODO: implements this.
            // TheCareerTasks->HandleEvent( EVENT_BOMB_DEFUSING, NULL, NULL );
        }

        if( pPlayer->m_fHasDefuseKit )
        {
            UTIL_LogPrintf(	"\"%s<%i><%s><CT>\" triggered \"Begin_Bomb_Defuse_With_Kit\"\n",
                            STRING( pPlayer->pev->netname ),
                            GETPLAYERAUTHID( pPlayer->edict() ),
                            GETPLAYERUSERID( pPlayer->edict() ) );

            ClientPrint( pPlayer->pev, HUD_PRINTCENTER, "#Defusing_Bomb_With_Defuse_Kit" );
            EMIT_SOUND( ENT( pPlayer->pev ), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM );

            pPlayer->m_fBombDefusing = TRUE;

            m_hActivator	= pActivator;
            m_fStartDefuse	= TRUE;

            m_flDefuseCountDown	= gpGlobals->time + 5.0;
            m_flNextDefuseTime	= gpGlobals->time + 0.5;

            barTime = 5;
        }
        else
        {
            UTIL_LogPrintf(	"\"%s<%i><%s><CT>\" triggered \"Begin_Bomb_Defuse_Without_Kit\"\n",
                            STRING( pPlayer->pev->netname ),
                            GETPLAYERAUTHID( pPlayer->edict() ),
                            GETPLAYERUSERID( pPlayer->edict() ) );

            ClientPrint( pPlayer->pev, HUD_PRINTCENTER, "#Defusing_Bomb_Without_Defuse_Kit" );
            EMIT_SOUND( ENT( pPlayer->pev ), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM );

            pPlayer->m_fBombDefusing = TRUE;

            m_hActivator	= pActivator;
            m_fStartDefuse	= TRUE;

            m_flDefuseCountDown	= gpGlobals->time + 10.0;
            m_flNextDefuseTime	= gpGlobals->time + 0.5;

            barTime = 10;
        }

        pPlayer->SetProgressBarTime( barTime );
    }
}
示例#21
0
void CGrenade::C4Think( void )
{
    if( !IsInWorld() )
    {
        UTIL_Remove( this );
        return;
    }

    pev->nextthink = gpGlobals->time + 0.12;

    if( m_flNextFreq <= gpGlobals->time )
    {
        m_flNextFreq = gpGlobals->time + m_flNextFreqInterval;
        m_flNextFreqInterval *= 0.9;

        switch( m_iC4Beep )
        {
        case 0 :
        {
            m_flAttenu = 1.5;
            m_sBeepName = "weapons/c4_beep1.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 140 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 1 :
        {
            m_flAttenu = 1.0;
            m_sBeepName = "weapons/c4_beep2.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 70 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 2 :
        {
            m_flAttenu = 0.8;
            m_sBeepName = "weapons/c4_beep3.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 40 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 3 :
        {
            m_flAttenu = 0.5;
            m_sBeepName = "weapons/c4_beep4.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 30 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 4 :
        {
            m_flAttenu = 0.2;
            m_sBeepName = "weapons/c4_beep5.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 20 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        }

        ++m_iC4Beep;
    }

    if( m_flNextBeep <= gpGlobals->time )
    {
        m_flNextBeep = gpGlobals->time + 1.4;
        EMIT_SOUND( ENT( pev ), CHAN_VOICE, m_sBeepName, VOL_NORM, m_flAttenu );

        // TODO: Adds support for bots.
        // TheBots->OnEvent( EVENT_BOMB_BEEP, this, NULL );
    }

    if( m_flNextBlink <= gpGlobals->time )
    {
        m_flNextBlink = gpGlobals->time	+ 2.0;

        MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
        WRITE_BYTE( TE_GLOWSPRITE );
        WRITE_COORD( pev->origin.x );
        WRITE_COORD( pev->origin.y );
        WRITE_COORD( pev->origin.z + 5.0 );
        WRITE_SHORT( g_sModelIndexC4Glow );
        WRITE_BYTE( 1 );
        WRITE_BYTE( 3 );
        WRITE_BYTE( 255 );
        MESSAGE_END();
    }

    if( m_flC4Blow <= gpGlobals->time )
    {
        // TODO: Adds support for bots.
        // TheBots->OnEvent( EVENT_BOMB_EXPLODED, NULL, NULL );

        MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
        WRITE_BYTE( 0 );
        MESSAGE_END();

        if( m_pentCurBombTarget )
        {
            CBaseEntity *pEntity = CBaseEntity::Instance( m_pentCurBombTarget->pev );

            if( pEntity )
            {
                CBaseEntity* pPlayer = CBaseEntity::Instance( pev->owner );

                if( pPlayer )
                {
                    pEntity->Use( pPlayer, this, USE_TOGGLE, 0 );
                }
            }
        }

        CBasePlayer* pPlayer = (CBasePlayer *)CBaseEntity::Instance( pev->owner );

        if( pPlayer )
        {
            pPlayer->pev->frags += 3;
        }

        MESSAGE_BEGIN( MSG_ALL, gmsgBombPickup );
        MESSAGE_END();

        g_pGameRules->m_fBombDropped = FALSE;

        if( pev->waterlevel )
            UTIL_Remove( this );
        else
            SetThink( &CGrenade::Detonate2 );
    }

    if( m_fStartDefuse )
    {
        CBasePlayer* pDefuser = (CBasePlayer *)((CBaseEntity *)m_hDefuser);

        if( pDefuser && m_flDefuseCountDown > gpGlobals->time )
        {
            BOOL isOnGround = !!( pDefuser->pev->flags & FL_ONGROUND );

            if( m_flNextDefuseTime < gpGlobals->time || !isOnGround )
            {
                if( !isOnGround )
                {
                    ClientPrint( m_hDefuser->pev, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground" );
                }

                pDefuser->ResetMaxSpeed();
                pDefuser->SetProgressBarTime( 0 );
                pDefuser->m_fBombDefusing = FALSE;

                m_fStartDefuse = FALSE;
                m_flDefuseCountDown = 0.0;

                // TODO: Adds support for bots.
                // TheBots->OnEvent( EVENT_DEFUSE_ABORTED, NULL, NULL );
            }
        }
        else
        {
            // TODO: Adds support for bots.
            // TheBots->OnEvent( EVENT_BOMB_DEFUSED, pDefuser, NULL );

            Broadcast( "BOMBDEF" );

            MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR );
            WRITE_BYTE( 9 );
            WRITE_BYTE( DRC_CMD_EVENT );
            WRITE_SHORT( ENTINDEX( this->edict() ) );
            WRITE_SHORT( NULL );
            WRITE_ENTITY( DRC_FLAG_FINAL | DRC_FLAG_FACEPLAYER | DRC_FLAG_DRAMATIC | 15 );
            MESSAGE_END();

            UTIL_LogPrintf(	"\"%s<%i><%s><CT>\" triggered \"Defused_The_Bomb\"\n",
                            STRING( pDefuser->pev->netname ),
                            GETPLAYERAUTHID( pDefuser->edict() ),
                            GETPLAYERUSERID( pDefuser->edict() ) );

            UTIL_EmitAmbientSound( ENT( pev ), pev->origin, "weapons/c4_beep5.wav", 0, ATTN_NONE, SND_STOP, 0 );
            EMIT_SOUND( ENT( pDefuser->pev ), CHAN_WEAPON, "weapons/c4_disarmed.wav", 0.8, ATTN_NORM );

            UTIL_Remove( this );
            m_fJustBlew = TRUE;

            pDefuser->ResetMaxSpeed();
            pDefuser->m_fBombDefusing = FALSE;

            MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
            WRITE_BYTE( 0 );
            MESSAGE_END();

            if( g_pGameRules->IsCareer() )
            {
                // TODO: Adds support for bots.
                //TheCareerTasks->HandleEvents( EVEN_BOMB_DEFUSED, pDefuser, NULL );
            }

            g_pGameRules->m_bBombDefused = TRUE;
            g_pGameRules->CheckWinConditions();

            pDefuser->pev->frags += 3;

            MESSAGE_BEGIN( MSG_ALL, gmsgBombPickup );
            MESSAGE_END();

            g_pGameRules->m_fBombDropped = FALSE;
            m_fStartDefuse = FALSE;
        }
    }
}
示例#22
0
//// HOST_SAY
// String comes in as
// say blah blah blah
// or as
// blah blah blah
//
void Host_Say( edict_t *pEntity, int teamonly )
{
	CBasePlayer *client;
	int		j;
	char	*p;
	char	text[128];
	char    szTemp[256];
	const char *cpSay = "say";
	const char *cpSayTeam = "say_team";
	const char *pcmd = CMD_ARGV(0);

	// We can get a raw string now, without the "say " prepended
	if ( CMD_ARGC() == 0 )
		return;

	entvars_t *pev = &pEntity->v;
	CBasePlayer* player = GetClassPtr((CBasePlayer *)pev);

	//Not yet.
	if ( player->m_flNextChatTime > gpGlobals->time )
		 return;

	if ( !stricmp( pcmd, cpSay) || !stricmp( pcmd, cpSayTeam ) )
	{
		if ( CMD_ARGC() >= 2 )
		{
			p = (char *)CMD_ARGS();
		}
		else
		{
			// say with a blank message, nothing to do
			return;
		}
	}
	else  // Raw text, need to prepend argv[0]
	{
		if ( CMD_ARGC() >= 2 )
		{
			sprintf( szTemp, "%s %s", ( char * )pcmd, (char *)CMD_ARGS() );
		}
		else
		{
			// Just a one word command, use the first word...sigh
			sprintf( szTemp, "%s", ( char * )pcmd );
		}
		p = szTemp;
	}

// remove quotes if present
	if (*p == '"')
	{
		p++;
		p[strlen(p)-1] = 0;
	}

// make sure the text has content
	char *pc;
	for ( pc = p; pc != NULL && *pc != 0; pc++ )
	{
		if ( !isspace( *pc ) )
		{
			pc = NULL;	// we've found an alphanumeric character,  so text is valid
			break;
		}
	}
	if ( pc != NULL )
		return;  // no character found, so say nothing

// turn on color set 2  (color on,  no sound)
	if ( teamonly )
		sprintf( text, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) );
	else
		sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) );

	j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
	if ( (int)strlen(p) > j )
		p[j] = 0;

	strcat( text, p );
	strcat( text, "\n" );


	player->m_flNextChatTime = gpGlobals->time + CHAT_INTERVAL;

	// loop through all players
	// Start with the first player.
	// This may return the world in single player if the client types something between levels or during spawn
	// so check it, or it will infinite loop

	client = NULL;
	while ( ((client = (CBasePlayer*)UTIL_FindEntityByClassname( client, "player" )) != NULL) && (!FNullEnt(client->edict())) ) 
	{
		if ( !client->pev )
			continue;
		
		if ( client->edict() == pEntity )
			continue;

		if ( !(client->IsNetClient()) )	// Not a client ? (should never be true)
			continue;

		// can the receiver hear the sender? or has he muted him?
		if ( g_VoiceGameMgr.PlayerHasBlockedPlayer( client, player ) )
			continue;

		if ( teamonly && g_pGameRules->PlayerRelationship(client, CBaseEntity::Instance(pEntity)) != GR_TEAMMATE )
			continue;

		MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, client->pev );
			WRITE_BYTE( ENTINDEX(pEntity) );
			WRITE_STRING( text );
		MESSAGE_END();

	}

	// print to the sending client
	MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, &pEntity->v );
		WRITE_BYTE( ENTINDEX(pEntity) );
		WRITE_STRING( text );
	MESSAGE_END();

	// echo to server console
	g_engfuncs.pfnServerPrint( text );

	char * temp;
	if ( teamonly )
		temp = "say_team";
	else
		temp = "say";
	
	// team match?
	if ( g_teamplay )
	{
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" %s \"%s\"\n", 
			STRING( pEntity->v.netname ), 
			GETPLAYERUSERID( pEntity ),
			GETPLAYERAUTHID( pEntity ),
			g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pEntity ), "model" ),
			temp,
			p );
	}
	else
	{
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" %s \"%s\"\n", 
			STRING( pEntity->v.netname ), 
			GETPLAYERUSERID( pEntity ),
			GETPLAYERAUTHID( pEntity ),
			GETPLAYERUSERID( pEntity ),
			temp,
			p );
	}
}
示例#23
0
void CC4::PrimaryAttack(void)
{
	if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
		return;

	BOOL onBombZone = m_pPlayer->m_signals.GetState() & SIGNAL_BOMB;
	BOOL onGround = m_pPlayer->pev->flags & FL_ONGROUND;

	if (!m_bStartedArming)
	{
		if (!onBombZone)
		{
			ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_At_Bomb_Spot");
			m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1;
			return;
		}

		if (!onGround)
		{
			ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
			m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1;
			return;
		}

		m_bStartedArming = true;
		m_bBombPlacedAnimation = false;
		m_fArmedTime = gpGlobals->time + 3;
		SendWeaponAnim(C4_ARM, UseDecrement() != FALSE);
		g_engfuncs.pfnSetClientMaxspeed(ENT(m_pPlayer->pev), 1);
		m_pPlayer->SetAnimation(PLAYER_ATTACK1);
		m_pPlayer->SetProgressBarTime(3);
		m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3;
		m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + RANDOM_FLOAT(10, 15);
	}
	else
	{
		if (!onGround || !onBombZone)
		{
			if (onBombZone)
				ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
			else
				ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Arming_Cancelled");

			m_bStartedArming = false;
			m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5;
			m_pPlayer->ResetMaxSpeed();
			m_pPlayer->SetProgressBarTime(0);
			m_pPlayer->SetAnimation(PLAYER_HOLDBOMB);

			if (m_bBombPlacedAnimation == true)
				SendWeaponAnim(C4_DRAW, UseDecrement() != FALSE);
			else
				SendWeaponAnim(C4_IDLE1, UseDecrement() != FALSE);

			return;
		}

		if (gpGlobals->time > m_fArmedTime)
		{
			if (m_bStartedArming == true)
			{
				m_bStartedArming = false;
				m_fArmedTime = 0;
				Broadcast("BOMBPL");
				m_pPlayer->m_bHasC4 = false;

#ifndef CLIENT_WEAPONS
				if (pev->speed != 0 && g_pGameRules)
					g_pGameRules->m_iC4Timer = (int)pev->speed;
#endif

				CGrenade *pGrenade = CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0));

				MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
				WRITE_BYTE(9);
				WRITE_BYTE(DRC_CMD_EVENT);
				WRITE_SHORT(ENTINDEX(m_pPlayer->edict()));
				WRITE_SHORT(0);
				WRITE_LONG(11 | DRC_FLAG_FACEPLAYER);
				MESSAGE_END();

#ifndef CLIENT_WEAPONS
				MESSAGE_BEGIN(MSG_ALL, gmsgBombDrop);
				WRITE_COORD(pGrenade->pev->origin.x);
				WRITE_COORD(pGrenade->pev->origin.y);
				WRITE_COORD(pGrenade->pev->origin.z);
				WRITE_BYTE(1);
				MESSAGE_END();
#endif

				UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Bomb_Planted");

#ifndef CLIENT_WEAPONS
				if (g_pGameRules->IsCareer() && !m_pPlayer->IsBot())
				{
				}
#endif

				UTIL_LogPrintf("\"%s<%i><%s><TERRORIST>\" triggered \"Planted_The_Bomb\"\n", STRING(m_pPlayer->pev->netname), GETPLAYERUSERID(m_pPlayer->edict()), GETPLAYERAUTHID(m_pPlayer->edict()));

#ifndef CLIENT_WEAPONS
				g_pGameRules->m_bBombDropped = false;
#endif
				EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/c4_plant.wav", VOL_NORM, ATTN_NORM);

				m_pPlayer->pev->body = 0;
				m_pPlayer->ResetMaxSpeed();
				m_pPlayer->SetBombIcon(FALSE);
				m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;

				if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
				{
					RetireWeapon();
					return;
				}
			}
		}
		else
		{
			if (gpGlobals->time >= m_fArmedTime - 0.75)
			{
				if (m_bBombPlacedAnimation == false)
				{
					m_bBombPlacedAnimation = true;
					SendWeaponAnim(C4_DROP, UseDecrement() != FALSE);
					m_pPlayer->SetAnimation(PLAYER_HOLDBOMB);
				}
			}
		}
	}

	m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3;
	m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + RANDOM_FLOAT(10, 15);
}
void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl )
{
	// notify other clients of player joining the game
	UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has joined the game\n", 
		( pl->pev->netname && STRING(pl->pev->netname)[0] != 0 ) ? STRING(pl->pev->netname) : "unconnected" ) );

	// team match?
	if ( g_teamplay )
	{
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" entered the game\n",  
			STRING( pl->pev->netname ), 
			GETPLAYERUSERID( pl->edict() ),
			GETPLAYERAUTHID( pl->edict() ),
			g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pl->edict() ), "model" ) );
	}
	else
	{
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" entered the game\n",  
			STRING( pl->pev->netname ), 
			GETPLAYERUSERID( pl->edict() ),
			GETPLAYERAUTHID( pl->edict() ),
			GETPLAYERUSERID( pl->edict() ) );
	}

	UpdateGameMode( pl );

	// sending just one score makes the hud scoreboard active;  otherwise
	// it is just disabled for single play
	MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, nullptr, pl->edict() );
		WRITE_BYTE( ENTINDEX(pl->edict()) );
		WRITE_SHORT( 0 );
		WRITE_SHORT( 0 );
		WRITE_SHORT( 0 );
		WRITE_SHORT( 0 );
	MESSAGE_END();

	SendMOTDToClient( pl->edict() );

	// loop through all active players and send their score info to the new client
	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		// FIXME:  Probably don't need to cast this just to read m_iDeaths
		CBasePlayer *plr = (CBasePlayer *)UTIL_PlayerByIndex( i );

		if ( plr )
		{
			MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, nullptr, pl->edict() );
				WRITE_BYTE( i );	// client number
				WRITE_SHORT( plr->pev->frags );
				WRITE_SHORT( plr->m_iDeaths );
				WRITE_SHORT( 0 );
				WRITE_SHORT( GetTeamIndex( plr->m_szTeamName ) + 1 );
			MESSAGE_END();
		}
	}

	if ( g_fGameOver )
	{
		MESSAGE_BEGIN( MSG_ONE, SVC_INTERMISSION, nullptr, pl->edict() );
		MESSAGE_END();
	}
}
//=========================================================
// Deathnotice. 
//=========================================================
void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor )
{
	// Work out what killed the player, and send a message to all clients about it
	CBaseEntity *Killer = CBaseEntity::Instance( pKiller );

	const char *killer_weapon_name = "world";		// by default, the player is killed by the world
	int killer_index = 0;
	
	// Hack to fix name change
	char *tau = "tau_cannon";
	char *gluon = "gluon gun";

	if ( pKiller->flags & FL_CLIENT )
	{
		killer_index = ENTINDEX(ENT(pKiller));
		
		if ( pevInflictor )
		{
			if ( pevInflictor == pKiller )
			{
				// If the inflictor is the killer,  then it must be their current weapon doing the damage
				CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pKiller );
				
				if ( pPlayer->m_pActiveItem )
				{
					killer_weapon_name = pPlayer->m_pActiveItem->pszName();
				}
			}
			else
			{
				killer_weapon_name = STRING( pevInflictor->classname );  // it's just that easy
			}
		}
	}
	else
	{
		killer_weapon_name = STRING( pevInflictor->classname );
	}

	// strip the monster_* or weapon_* from the inflictor's classname
	if ( strncmp( killer_weapon_name, "weapon_", 7 ) == 0 )
		killer_weapon_name += 7;
	else if ( strncmp( killer_weapon_name, "monster_", 8 ) == 0 )
		killer_weapon_name += 8;
	else if ( strncmp( killer_weapon_name, "func_", 5 ) == 0 )
		killer_weapon_name += 5;

	MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
		WRITE_BYTE( killer_index );						// the killer
		WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
		WRITE_STRING( killer_weapon_name );		// what they were killed by (should this be a string?)
	MESSAGE_END();

	// replace the code names with the 'real' names
	if ( !strcmp( killer_weapon_name, "egon" ) )
		killer_weapon_name = gluon;
	else if ( !strcmp( killer_weapon_name, "gauss" ) )
		killer_weapon_name = tau;

	if ( pVictim->pev == pKiller )  
	{
		// killed self

		// team match?
		if ( g_teamplay )
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\"\n",  
				STRING( pVictim->pev->netname ), 
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pVictim->edict() ), "model" ),
				killer_weapon_name );		
		}
		else
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"%s\"\n",  
				STRING( pVictim->pev->netname ), 
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				GETPLAYERUSERID( pVictim->edict() ),
				killer_weapon_name );		
		}
	}
	else if ( pKiller->flags & FL_CLIENT )
	{
		// team match?
		if ( g_teamplay )
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%s>\" killed \"%s<%i><%s><%s>\" with \"%s\"\n",  
				STRING( pKiller->netname ),
				GETPLAYERUSERID( ENT(pKiller) ),
				GETPLAYERAUTHID( ENT(pKiller) ),
				g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( ENT(pKiller) ), "model" ),
				STRING( pVictim->pev->netname ),
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pVictim->edict() ), "model" ),
				killer_weapon_name );
		}
		else
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" killed \"%s<%i><%s><%i>\" with \"%s\"\n",  
				STRING( pKiller->netname ),
				GETPLAYERUSERID( ENT(pKiller) ),
				GETPLAYERAUTHID( ENT(pKiller) ),
				GETPLAYERUSERID( ENT(pKiller) ),
				STRING( pVictim->pev->netname ),
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				GETPLAYERUSERID( pVictim->edict() ),
				killer_weapon_name );
		}
	}
	else
	{ 
		// killed by the world

		// team match?
		if ( g_teamplay )
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\" (world)\n",
				STRING( pVictim->pev->netname ), 
				GETPLAYERUSERID( pVictim->edict() ), 
				GETPLAYERAUTHID( pVictim->edict() ),
				g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pVictim->edict() ), "model" ),
				killer_weapon_name );		
		}
		else
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"%s\" (world)\n",
				STRING( pVictim->pev->netname ), 
				GETPLAYERUSERID( pVictim->edict() ), 
				GETPLAYERAUTHID( pVictim->edict() ),
				GETPLAYERUSERID( pVictim->edict() ),
				killer_weapon_name );		
		}
	}

	MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR );
		WRITE_BYTE ( 9 );	// command length in bytes
		WRITE_BYTE ( DRC_CMD_EVENT );	// player killed
		WRITE_SHORT( ENTINDEX(pVictim->edict()) );	// index number of primary entity
		if (pevInflictor)
			WRITE_SHORT( ENTINDEX(ENT(pevInflictor)) );	// index number of secondary entity
		else
			WRITE_SHORT( ENTINDEX(ENT(pKiller)) );	// index number of secondary entity
		WRITE_LONG( 7 | DRC_FLAG_DRAMATIC);   // eventflags (priority and flags)
	MESSAGE_END();

//  Print a standard message
	// TODO: make this go direct to console
	return; // just remove for now
/*
	char	szText[ 128 ];

	if ( pKiller->flags & FL_MONSTER )
	{
		// killed by a monster
		strcpy ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, " was killed by a monster.\n" );
		return;
	}

	if ( pKiller == pVictim->pev )
	{
		strcpy ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, " commited suicide.\n" );
	}
	else if ( pKiller->flags & FL_CLIENT )
	{
		strcpy ( szText, STRING( pKiller->netname ) );

		strcat( szText, " : " );
		strcat( szText, killer_weapon_name );
		strcat( szText, " : " );

		strcat ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, "\n" );
	}
	else if ( FClassnameIs ( pKiller, "worldspawn" ) )
	{
		strcpy ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, " fell or drowned or something.\n" );
	}
	else if ( pKiller->solid == SOLID_BSP )
	{
		strcpy ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, " was mooshed.\n" );
	}
	else
	{
		strcpy ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, " died mysteriously.\n" );
	}

	UTIL_ClientPrintAll( szText );
*/
}
/*
=========================================================
UpdateClientData

resends any changed player HUD info to the client.
Called every frame by PlayerPreThink
Also called at start of demo recording and playback by
ForceClientDllUpdate to ensure the demo gets messages
reflecting all of the HUD state info.
=========================================================
*/
void CBasePlayer::UpdateClientData()
{
	if( m_bNeedsNewConnectTime )
	{
		m_bNeedsNewConnectTime = false;

		m_flConnectTime = gpGlobals->time;
	}

	if( !m_bWeaponValidationReceived && m_flConnectTime + WEAPON_VALIDATION_GRACE_TIME < gpGlobals->time )
	{
		//If the client didn't send the message in time, drop the client. - Solokiller

		//Set it to true to avoid running this multiple times. - Solokiller
		m_bWeaponValidationReceived = true;

		UTIL_LogPrintf( "Player \"%s\" didn't send weapon validation in time, disconnecting\n", GetNetName() );

		if( !IS_DEDICATED_SERVER() )
		{
			//Listen server hosts usually don't have logging enabled, so echo to console unconditionally for them. - Solokiller
			UTIL_ServerPrintf( "Player \"%s\" didn't send weapon validation in time, disconnecting\n", GetNetName() );
		}

		if( IS_DEDICATED_SERVER() || entindex() != 1 )
		{
			SERVER_COMMAND( UTIL_VarArgs( "kick \"%s\" \"No weapon validation received\"\n", GetNetName() ) );
		}
		else
		{
			//The local player can't be kicked, so terminate the session instead - Solokiller
			CLIENT_COMMAND( edict(), "disconnect\n" );
		}
	}

	//The engine will not call ClientPutInServer after transitions, so we'll have to catch this event every map change. - Solokiller
	if( !m_bSentInitData )
	{
		m_bSentInitData = true;

		//Update Hud colors. - Solokiller
		CMap::GetInstance()->SendHudColors( this, true );
	}

	if( m_fInitHUD )
	{
		m_fInitHUD = false;
		gInitHUD = false;

		MESSAGE_BEGIN( MSG_ONE, gmsgResetHUD, NULL, this );
			WRITE_BYTE( 0 );
		MESSAGE_END();

		if( !m_fGameHUDInitialized )
		{
			MESSAGE_BEGIN( MSG_ONE, gmsgInitHUD, NULL, this );
			MESSAGE_END();

			g_pGameRules->InitHUD( this );
			m_fGameHUDInitialized = true;

			m_iObserverLastMode = OBS_ROAMING;

			if( g_pGameRules->IsMultiplayer() )
			{
				FireTargets( "game_playerjoin", this, this, USE_TOGGLE, 0 );
			}
		}

		FireTargets( "game_playerspawn", this, this, USE_TOGGLE, 0 );

		InitStatusBar();

		SendWeatherUpdate();
	}

	if( m_iHideHUD != m_iClientHideHUD )
	{
		MESSAGE_BEGIN( MSG_ONE, gmsgHideWeapon, NULL, this );
			WRITE_BYTE( m_iHideHUD );
		MESSAGE_END();

		m_iClientHideHUD = m_iHideHUD;
	}

	if( m_iFOV != m_iClientFOV )
	{
		MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, this );
			WRITE_BYTE( m_iFOV );
		MESSAGE_END();

		// cache FOV change at end of function, so weapon updates can see that FOV has changed
	}

	// HACKHACK -- send the message to display the game title
	if( gDisplayTitle )
	{
		MESSAGE_BEGIN( MSG_ONE, gmsgShowGameTitle, NULL, this );
			WRITE_BYTE( 0 );
		MESSAGE_END();
		gDisplayTitle = false;
	}

	if( pev->health != m_iClientHealth )
	{
		int iHealth = clamp( static_cast<int>( pev->health ), 0, 255 );  // make sure that no negative health values are sent
		if( pev->health > 0.0f && pev->health <= 1.0f )
			iHealth = 1;

		// send "health" update message
		MESSAGE_BEGIN( MSG_ONE, gmsgHealth, NULL, this );
			WRITE_BYTE( iHealth );
		MESSAGE_END();

		m_iClientHealth = pev->health;
	}


	if( pev->armorvalue != m_iClientBattery )
	{
		m_iClientBattery = pev->armorvalue;

		ASSERT( gmsgBattery > 0 );
		// send "health" update message
		MESSAGE_BEGIN( MSG_ONE, gmsgBattery, NULL, this );
			WRITE_SHORT( ( int ) pev->armorvalue );
		MESSAGE_END();
	}

	if( pev->dmg_take || pev->dmg_save || m_bitsHUDDamage != m_bitsDamageType )
	{
		// Comes from inside me if not set
		Vector damageOrigin = GetAbsOrigin();
		// send "damage" message
		// causes screen to flash, and pain compass to show direction of damage
		edict_t *other = pev->dmg_inflictor;
		if( other )
		{
			CBaseEntity *pEntity = CBaseEntity::Instance( other );
			if( pEntity )
				damageOrigin = pEntity->Center();
		}

		// only send down damage type that have hud art
		int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD;

		MESSAGE_BEGIN( MSG_ONE, gmsgDamage, NULL, this );
			WRITE_BYTE( pev->dmg_save );
			WRITE_BYTE( pev->dmg_take );
			WRITE_LONG( visibleDamageBits );
			WRITE_COORD( damageOrigin.x );
			WRITE_COORD( damageOrigin.y );
			WRITE_COORD( damageOrigin.z );
		MESSAGE_END();

		//TODO: both of these can probably be removed. - Solokiller
		pev->dmg_take = 0;
		pev->dmg_save = 0;
		m_bitsHUDDamage = m_bitsDamageType;

		// Clear off non-time-based damage indicators
		m_bitsDamageType &= DMG_TIMEBASED;
	}

	// Update Flashlight
	if( ( m_flFlashLightTime ) && ( m_flFlashLightTime <= gpGlobals->time ) )
	{
		if( FlashlightIsOn() )
		{
			if( m_iFlashBattery )
			{
				m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time;
				m_iFlashBattery--;

				if( !m_iFlashBattery )
					FlashlightTurnOff();
			}
		}
		else
		{
			if( m_iFlashBattery < 100 )
			{
				m_flFlashLightTime = FLASH_CHARGE_TIME + gpGlobals->time;
				m_iFlashBattery++;
			}
			else
				m_flFlashLightTime = 0;
		}

		MESSAGE_BEGIN( MSG_ONE, gmsgFlashBattery, NULL, this );
			WRITE_BYTE( m_iFlashBattery );
		MESSAGE_END();
	}

	if( m_iTrain & TRAIN_NEW )
	{
		ASSERT( gmsgTrain > 0 );
		// send "health" update message
		MESSAGE_BEGIN( MSG_ONE, gmsgTrain, NULL, this );
			WRITE_BYTE( m_iTrain & 0xF );
		MESSAGE_END();

		m_iTrain &= ~TRAIN_NEW;
	}

	SendAmmoUpdate();

	// Update all the items
	for( int i = 0; i < MAX_WEAPON_SLOTS; i++ )
	{
		if( m_rgpPlayerItems[ i ] )  // each item updates it's successors
			m_rgpPlayerItems[ i ]->UpdateClientData( this );
	}

	// Cache and client weapon change
	m_pClientActiveItem = m_pActiveItem;
	m_iClientFOV = m_iFOV;

	// Update Status Bar
	if( m_flNextSBarUpdateTime < gpGlobals->time )
	{
		UpdateStatusBar();
		m_flNextSBarUpdateTime = gpGlobals->time + 0.2;
	}
}
示例#27
0
//=========================================================
// Deathnotice. 
//=========================================================
void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor )
{
	// Work out what killed the player, and send a message to all clients about it
	CBaseEntity *Killer = CBaseEntity::Instance( pKiller );

	const char *killer_weapon_name = "world";		// by default, the player is killed by the world
	int killer_index = 0;
	
	// Hack to fix name change

	if ( pKiller->flags & FL_CLIENT )
	{
		killer_index = ENTINDEX(ENT(pKiller));
		
		if ( pevInflictor )
		{
			if ( pevInflictor == pKiller )
			{
				// If the inflictor is the killer,  then it must be their current weapon doing the damage
				CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pKiller );
				
				if ( pPlayer->m_pActiveItem )
				{
					killer_weapon_name = pPlayer->m_pActiveItem->pszName();
				}
			}
			else
			{
				killer_weapon_name = STRING( pevInflictor->classname );  // it's just that easy
			}
		}
	}
	else
	{
		killer_weapon_name = STRING( pevInflictor->classname );
	}

	// strip the monster_* or weapon_* from the inflictor's classname
	if ( strncmp( killer_weapon_name, "weapon_", 7 ) == 0 )
		killer_weapon_name += 7;
	else if ( strncmp( killer_weapon_name, "monster_", 8 ) == 0 )
		killer_weapon_name += 8;
	else if ( strncmp( killer_weapon_name, "func_", 5 ) == 0 )
		killer_weapon_name += 5;

	if ( pVictim->pev == pKiller )  
	{  
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"%s\"\n",  
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ),
			GETPLAYERAUTHID( pVictim->edict() ),
			GETPLAYERUSERID( pVictim->edict() ),
			killer_weapon_name );	
		
		pKiller->frags -= 1;
	}
	else if ( pKiller->flags & FL_CLIENT )
	{
		if ( !strcmp( killer_weapon_name, "disc" ) )
		{
			int iTele = 0;
			if ( (pVictim->m_flLastDiscHitTeleport != 0) && (gpGlobals->time < pVictim->m_flLastDiscHitTeleport + MAX_SCORE_TIME_AFTER_HIT) )
				iTele = REWARD_TELEPORT;

			// Decapitated?
			if ( pVictim->m_LastHitGroup == HITGROUP_HEAD )
			{
				UTIL_LogPrintf( "\"%s<%i><%s><%i>\" killed \"%s<%i><%s><%i>\" with \"%s\" (decapitated)\n",  
					STRING( pKiller->netname ),
					GETPLAYERUSERID( ENT(pKiller) ),
					GETPLAYERAUTHID( ENT(pKiller) ),
					GETPLAYERUSERID( ENT(pKiller) ),
					STRING( pVictim->pev->netname ),
					GETPLAYERUSERID( pVictim->edict() ),
					GETPLAYERAUTHID( pVictim->edict() ),
					GETPLAYERUSERID( pVictim->edict() ),
					killer_weapon_name );

				// Tell the client to display the death message
				MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
					WRITE_BYTE( killer_index );						// the killer
					WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
					WRITE_STRING( "decapitate" );					// what they were killed by (should this be a string?)
				MESSAGE_END();

				// Bonus point for teleport hit
				if ( iTele )
					pKiller->frags++;

				pKiller->frags += 1;

				// Bring up the reward window on the killer's screen
				MESSAGE_BEGIN( MSG_ONE, gmsgReward, NULL, Killer->edict() );
					WRITE_SHORT( REWARD_DECAPITATE | iTele );
				MESSAGE_END();

				return;
			}

			// Otherwise, calculate number of disc bounces
			if ( pVictim->m_iLastDiscBounces == 0 )
			{
				// Bring up the reward window on the killer's screen
				MESSAGE_BEGIN( MSG_ONE, gmsgReward, NULL, Killer->edict() );
					WRITE_SHORT( REWARD_BOUNCE_NONE | iTele );
				MESSAGE_END();
			}
			else if ( pVictim->m_iLastDiscBounces == 1 )
			{
				// Bring up the reward window on the killer's screen
				MESSAGE_BEGIN( MSG_ONE, gmsgReward, NULL, Killer->edict() );
					WRITE_SHORT( REWARD_BOUNCE_ONE | iTele );
				MESSAGE_END();
			}
			else
			{
				if ( pVictim->m_iLastDiscBounces == 2 )
				{
					// Bring up the reward window on the killer's screen
					MESSAGE_BEGIN( MSG_ONE, gmsgReward, NULL, Killer->edict() );
						WRITE_SHORT( REWARD_BOUNCE_TWO | iTele );
					MESSAGE_END();
				}
				else
				{
					// Bring up the reward window on the killer's screen
					MESSAGE_BEGIN( MSG_ONE, gmsgReward, NULL, Killer->edict() );
						WRITE_SHORT( REWARD_BOUNCE_THREE | iTele );
					MESSAGE_END();

					// Cap the number of frags a killer can get to 4
					pVictim->m_iLastDiscBounces = 3;
				}
			}

			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" killed \"%s<%i><%s><%i>\" with \"%s\" (bounces \"%d\")\n",  
				STRING( pKiller->netname ),
				GETPLAYERUSERID( ENT(pKiller) ),
				GETPLAYERAUTHID( ENT(pKiller) ),
				GETPLAYERUSERID( ENT(pKiller) ),
				STRING( pVictim->pev->netname ),
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				GETPLAYERUSERID( pVictim->edict() ),
				killer_weapon_name,
				pVictim->m_iLastDiscBounces );

			char sz[1024];
			sprintf( sz, "%dbounce", pVictim->m_iLastDiscBounces );

			// Tell the client to display the death message
			MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
				WRITE_BYTE( killer_index );						// the killer
				WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
				WRITE_STRING( sz );								// what they were killed by (should this be a string?)
			MESSAGE_END();

			pKiller->frags += (1 + pVictim->m_iLastDiscBounces);

			// Bonus point for teleport hit
			if ( iTele )
				pKiller->frags++;
		}
		else
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" killed \"%s<%i><%s><%i>\" with \"%s\"\n",  
				STRING( pKiller->netname ),
				GETPLAYERUSERID( ENT(pKiller) ),
				GETPLAYERAUTHID( ENT(pKiller) ),
				GETPLAYERUSERID( ENT(pKiller) ),
				STRING( pVictim->pev->netname ),
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				GETPLAYERUSERID( pVictim->edict() ),
				killer_weapon_name );

			// Tell the client to display the death message
			MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
				WRITE_BYTE( killer_index );						// the killer
				WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
				WRITE_STRING( killer_weapon_name );				// what they were killed by (should this be a string?)
			MESSAGE_END();

			pKiller->frags += 1;
		}
	}
	else
	{  
		pKiller->frags -= 1;

		// Fell to their death
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"world\"\n",
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ), 
			GETPLAYERAUTHID( pVictim->edict() ),
			GETPLAYERUSERID( pVictim->edict() ),
			killer_weapon_name );		

		// Tell the client to display the death message
		MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
			WRITE_BYTE( killer_index );						// the killer
			WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
			WRITE_STRING( "falling" );						// what they were killed by (should this be a string?)
		MESSAGE_END();
	}

	return;
}
示例#28
0
/* <2464e8> ../cstrike/dlls/wpn_shared/wpn_c4.cpp:152 */
void CC4::__MAKE_VHOOK(PrimaryAttack)(void)
{
	BOOL PlaceBomb;
	int inBombZone, onGround;

	if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
	{
		return;
	}

	inBombZone = (m_pPlayer->m_signals.GetState() & SIGNAL_BOMB) == SIGNAL_BOMB;
	onGround = (m_pPlayer->pev->flags & FL_ONGROUND) == FL_ONGROUND;
	PlaceBomb = (onGround && inBombZone);

	if (!m_bStartedArming)
	{
		if (!inBombZone)
		{
			ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_At_Bomb_Spot");
			m_flNextPrimaryAttack = GetNextAttackDelay(1.0);
			return;
		}

		if (!onGround)
		{
			ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
			m_flNextPrimaryAttack = GetNextAttackDelay(1);
			return;
		}

		m_bStartedArming = true;
		m_bBombPlacedAnimation = false;
		m_fArmedTime = gpGlobals->time + C4_ARMING_ON_TIME;

		SendWeaponAnim(C4_ARM, UseDecrement() != FALSE);

		SET_CLIENT_MAXSPEED(m_pPlayer->edict(), 1.0);

		m_pPlayer->SetAnimation(PLAYER_ATTACK1);
		m_pPlayer->SetProgressBarTime(C4_ARMING_ON_TIME);
	}
	else
	{
		if (PlaceBomb)
		{
			CBaseEntity *pEntity = NULL;
			CBasePlayer *pTempPlayer = NULL;

			if (m_fArmedTime <= gpGlobals->time)
			{
				if (m_bStartedArming)
				{
					m_bStartedArming = false;
					m_fArmedTime = 0;

					Broadcast("BOMBPL");
					m_pPlayer->m_bHasC4 = false;

					if (pev->speed != 0 && g_pGameRules != NULL)
					{
						g_pGameRules->m_iC4Timer = (int)pev->speed;
					}

					CGrenade *pBomb = CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0));

					MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
						WRITE_BYTE(9);
						WRITE_BYTE(DRC_CMD_EVENT);
						WRITE_SHORT(m_pPlayer->entindex());
						WRITE_SHORT(0);
						WRITE_LONG(DRC_FLAG_FACEPLAYER | 11);
					MESSAGE_END();

					MESSAGE_BEGIN(MSG_ALL, gmsgBombDrop);
						WRITE_COORD(pBomb->pev->origin.x);
						WRITE_COORD(pBomb->pev->origin.y);
						WRITE_COORD(pBomb->pev->origin.z);
						WRITE_BYTE(1);
					MESSAGE_END();

					UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Bomb_Planted");

					TheBots->OnEvent(EVENT_BOMB_PLANTED, m_pPlayer, pBomb);

					if (g_pGameRules->IsCareer() && !m_pPlayer->IsBot())
					{
						TheCareerTasks->HandleEvent(EVENT_BOMB_PLANTED, m_pPlayer);
					}

					UTIL_LogPrintf
					(
						"\"%s<%i><%s><TERRORIST>\" triggered \"Planted_The_Bomb\"\n",
						STRING(m_pPlayer->pev->netname),
						GETPLAYERUSERID(m_pPlayer->edict()),
						GETPLAYERAUTHID(m_pPlayer->edict())
					);

					g_pGameRules->m_bBombDropped = FALSE;
					EMIT_SOUND(edict(), CHAN_WEAPON, "weapons/c4_plant.wav", VOL_NORM, ATTN_NORM);

					m_pPlayer->pev->body = 0;
					m_pPlayer->ResetMaxSpeed();
					m_pPlayer->SetBombIcon(FALSE);

					m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;

					if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
					{
						RetireWeapon();
						return;
					}
				}
			}
			else
			{
				if (m_fArmedTime - 0.75 <= gpGlobals->time && !m_bBombPlacedAnimation)
				{
					m_bBombPlacedAnimation = true;

					SendWeaponAnim(C4_DROP, UseDecrement() != FALSE);
					m_pPlayer->SetAnimation(PLAYER_HOLDBOMB);
				}
			}
		}
		else
		{
			if (inBombZone)
				ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
			else
				ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Arming_Cancelled");

			m_bStartedArming = false;
			m_flNextPrimaryAttack = GetNextAttackDelay(1.5);

			m_pPlayer->ResetMaxSpeed();
			m_pPlayer->SetProgressBarTime(0);
			m_pPlayer->SetAnimation(PLAYER_HOLDBOMB);

			SendWeaponAnim(m_bBombPlacedAnimation ? C4_DRAW : C4_IDLE1, UseDecrement() != FALSE);
			return;
		}
	}

	m_flNextPrimaryAttack = GetNextAttackDelay(0.3);
	m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + RANDOM_FLOAT(10, 15);
}
示例#29
0
void CHL2MPRules::ClientSettingsChanged( CBasePlayer *pPlayer )
{
#ifndef CLIENT_DLL

    CHL2MP_Player *pHL2Player = ToHL2MPPlayer( pPlayer );

    if ( pHL2Player == NULL )
        return;

    const char *pCurrentModel = modelinfo->GetModelName( pPlayer->GetModel() );
    const char *szModelName = engine->GetClientConVarValue( engine->IndexOfEdict( pPlayer->edict() ), "cl_playermodel" );

    //If we're different.
    if ( stricmp( szModelName, pCurrentModel ) )
    {
        //Too soon, set the cvar back to what it was.
        //Note: this will make this function be called again
        //but since our models will match it'll just skip this whole dealio.
        if ( pHL2Player->GetNextModelChangeTime() >= gpGlobals->curtime )
        {
            char szReturnString[512];

            Q_snprintf( szReturnString, sizeof (szReturnString ), "cl_playermodel %s\n", pCurrentModel );
            engine->ClientCommand ( pHL2Player->edict(), szReturnString );

            Q_snprintf( szReturnString, sizeof( szReturnString ), "Please wait %d more seconds before trying to switch.\n", (int)(pHL2Player->GetNextModelChangeTime() - gpGlobals->curtime) );
            ClientPrint( pHL2Player, HUD_PRINTTALK, szReturnString );
            return;
        }

        if ( HL2MPRules()->IsTeamplay() == false )
        {
            pHL2Player->SetPlayerModel();

            const char *pszCurrentModelName = modelinfo->GetModelName( pHL2Player->GetModel() );

            char szReturnString[128];
            Q_snprintf( szReturnString, sizeof( szReturnString ), "Your player model is: %s\n", pszCurrentModelName );

            ClientPrint( pHL2Player, HUD_PRINTTALK, szReturnString );
        }
        else
        {
            if ( Q_stristr( szModelName, "models/human") )
            {
                pHL2Player->ChangeTeam( TEAM_REBELS );
            }
            else
            {
                pHL2Player->ChangeTeam( TEAM_COMBINE );
            }
        }
    }
    if ( sv_report_client_settings.GetInt() == 1 )
    {
        UTIL_LogPrintf( "\"%s\" cl_cmdrate = \"%s\"\n", pHL2Player->GetPlayerName(), engine->GetClientConVarValue( pHL2Player->entindex(), "cl_cmdrate" ));
    }

    BaseClass::ClientSettingsChanged( pPlayer );
#endif

}
示例#30
0
//// HOST_SAY
// String comes in as
// say blah blah blah
// or as
// blah blah blah
//
void Host_Say( edict_t *pEdict, const CCommand &args, bool teamonly )
{
	CBasePlayer *client;
	int		j;
	char	*p;
	char	text[256];
	char    szTemp[256];
	const char *cpSay = "say";
	const char *cpSayTeam = "say_team";
	const char *pcmd = args[0];
	bool bSenderDead = false;

	// We can get a raw string now, without the "say " prepended
	if ( args.ArgC() == 0 )
		return;

	if ( !stricmp( pcmd, cpSay) || !stricmp( pcmd, cpSayTeam ) )
	{
		if ( args.ArgC() >= 2 )
		{
			p = (char *)args.ArgS();
		}
		else
		{
			// say with a blank message, nothing to do
			return;
		}
	}
	else  // Raw text, need to prepend argv[0]
	{
		if ( args.ArgC() >= 2 )
		{
			Q_snprintf( szTemp,sizeof(szTemp), "%s %s", ( char * )pcmd, (char *)args.ArgS() );
		}
		else
		{
			// Just a one word command, use the first word...sigh
			Q_snprintf( szTemp,sizeof(szTemp), "%s", ( char * )pcmd );
		}
		p = szTemp;
	}

	CBasePlayer *pPlayer = NULL;
	if ( pEdict )
	{
		pPlayer = ((CBasePlayer *)CBaseEntity::Instance( pEdict ));
		Assert( pPlayer );

		// make sure the text has valid content
		p = CheckChatText( pPlayer, p );
	}

	if ( !p )
		return;

	if ( pEdict )
	{
		if ( !pPlayer->CanSpeak() )
			return;

		// See if the player wants to modify of check the text
		pPlayer->CheckChatText( p, 127 );	// though the buffer szTemp that p points to is 256, 
											// chat text is capped to 127 in CheckChatText above

		Assert( strlen( pPlayer->GetPlayerName() ) > 0 );

		bSenderDead = ( pPlayer->m_lifeState != LIFE_ALIVE );
	}
	else
	{
		bSenderDead = false;
	}

	const char *pszFormat = NULL;
	const char *pszPrefix = NULL;
	const char *pszLocation = NULL;
	if ( g_pGameRules )
	{
		pszFormat = g_pGameRules->GetChatFormat( teamonly, pPlayer );
		pszPrefix = g_pGameRules->GetChatPrefix( teamonly, pPlayer );	
		pszLocation = g_pGameRules->GetChatLocation( teamonly, pPlayer );
	}

	const char *pszPlayerName = pPlayer ? pPlayer->GetPlayerName():"Console";

	if ( pszPrefix && strlen( pszPrefix ) > 0 )
	{
		if ( pszLocation && strlen( pszLocation ) )
		{
			Q_snprintf( text, sizeof(text), "%s %s @ %s: ", pszPrefix, pszPlayerName, pszLocation );
		}
		else
		{
			Q_snprintf( text, sizeof(text), "%s %s: ", pszPrefix, pszPlayerName );
		}
	}
	else
	{
		Q_snprintf( text, sizeof(text), "%s: ", pszPlayerName );
	}

	j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
	if ( (int)strlen(p) > j )
		p[j] = 0;

	Q_strncat( text, p, sizeof( text ), COPY_ALL_CHARACTERS );
	Q_strncat( text, "\n", sizeof( text ), COPY_ALL_CHARACTERS );
 
	// loop through all players
	// Start with the first player.
	// This may return the world in single player if the client types something between levels or during spawn
	// so check it, or it will infinite loop

	client = NULL;
	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		client = ToBaseMultiplayerPlayer( UTIL_PlayerByIndex( i ) );
		if ( !client || !client->edict() )
			continue;
		
		if ( client->edict() == pEdict )
			continue;

		if ( !(client->IsNetClient()) )	// Not a client ? (should never be true)
			continue;

		if ( teamonly && g_pGameRules->PlayerCanHearChat( client, pPlayer ) != GR_TEAMMATE )
			continue;

		if ( pPlayer && !client->CanHearAndReadChatFrom( pPlayer ) )
			continue;

		if ( pPlayer && GetVoiceGameMgr() && GetVoiceGameMgr()->IsPlayerIgnoringPlayer( pPlayer->entindex(), i ) )
			continue;

		CSingleUserRecipientFilter user( client );
		user.MakeReliable();

		if ( pszFormat )
		{
			UTIL_SayText2Filter( user, pPlayer, true, pszFormat, pszPlayerName, p, pszLocation );
		}
		else
		{
			UTIL_SayTextFilter( user, text, pPlayer, true );
		}
	}

	if ( pPlayer )
	{
		// print to the sending client
		CSingleUserRecipientFilter user( pPlayer );
		user.MakeReliable();

		if ( pszFormat )
		{
			UTIL_SayText2Filter( user, pPlayer, true, pszFormat, pszPlayerName, p, pszLocation );
		}
		else
		{
			UTIL_SayTextFilter( user, text, pPlayer, true );
		}
	}

	// echo to server console
	// Adrian: Only do this if we're running a dedicated server since we already print to console on the client.
	if ( engine->IsDedicatedServer() )
		 Msg( "%s", text );

	Assert( p );

	int userid = 0;
	const char *networkID = "Console";
	const char *playerName = "Console";
	const char *playerTeam = "Console";
	if ( pPlayer )
	{
		userid = pPlayer->GetUserID();
		networkID = pPlayer->GetNetworkIDString();
		playerName = pPlayer->GetPlayerName();
		CTeam *team = pPlayer->GetTeam();
		if ( team )
		{
			playerTeam = team->GetName();
		}
	}
		
	if ( teamonly )
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" say_team \"%s\"\n", playerName, userid, networkID, playerTeam, p );
	else
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" say \"%s\"\n", playerName, userid, networkID, playerTeam, p );

	IGameEvent * event = gameeventmanager->CreateEvent( "player_say" );

	if ( event )	// will be null if there are no listeners!
	{
		event->SetInt("userid", userid );
		event->SetString("text", p );
		event->SetInt("priority", 1 );	// HLTV event priority, not transmitted
		gameeventmanager->FireEvent( event );
	}
}