当前位置: 首页>>代码示例>>C++>>正文


C++ UserMessageBegin函数代码示例

本文整理汇总了C++中UserMessageBegin函数的典型用法代码示例。如果您正苦于以下问题:C++ UserMessageBegin函数的具体用法?C++ UserMessageBegin怎么用?C++ UserMessageBegin使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了UserMessageBegin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SendHelp

	void SendHelp( CGEPlayer *pPlayer )
	{
		if ( !pPlayer || pPlayer->IsBotPlayer() )
			return;

		CSingleUserRecipientFilter filter( pPlayer );
		filter.MakeReliable();

		// Send overall scenario help information
		UserMessageBegin( filter, "ScenarioHelp" );
			WRITE_STRING( GEGameplay()->GetScenario()->GetIdent() );
			WRITE_STRING( m_szHelpTagLine );
			WRITE_STRING( m_szHelpWebsite );
			WRITE_BYTE( m_iDefaultPane );
		MessageEnd();

		// Output each help item from each pane
		FOR_EACH_MAP( m_vHelpPanes, idx )
		{
			sHelpPane *pPane = m_vHelpPanes[idx];

			if ( pPane->nHelpString == INVALID_STRING_INDEX )
			{
				bool save = engine->LockNetworkStringTables( false );
				pPane->nHelpString = g_pStringTableGameplay->AddString( true, pPane->szHelpString );
				engine->LockNetworkStringTables( save );
			}

			UserMessageBegin( filter, "ScenarioHelpPane" );
				WRITE_BYTE( m_vHelpPanes.Key(idx) );
				WRITE_STRING( pPane->szHelpId );
				WRITE_SHORT( pPane->nHelpString );
			MessageEnd();
		}
开发者ID:Entropy-Soldier,项目名称:ges-legacy-code,代码行数:34,代码来源:ge_pygameplay.cpp

示例2: UserMessageBegin

//-----------------------------------------------------------------------------
// Purpose: Input handler for showing the message and/or playing the sound.
//-----------------------------------------------------------------------------
void CEnvHudHint::InputShowHudHint( inputdata_t &inputdata )
{
	if ( AllPlayers() )
	{
		CReliableBroadcastRecipientFilter user;
		UserMessageBegin( user, "KeyHintText" );
		WRITE_BYTE( 1 );	// one message
		WRITE_STRING( STRING(m_iszMessage) );
		MessageEnd();
	}
	else
	{
		CBaseEntity *pPlayer = NULL;
		if ( inputdata.pActivator && inputdata.pActivator->IsPlayer() )
		{
			pPlayer = inputdata.pActivator;
		}
		else
		{
			pPlayer = UTIL_GetNearestPlayer(GetAbsOrigin());
		}

		if ( !pPlayer || !pPlayer->IsNetClient() )
			return;

		CSingleUserRecipientFilter user( (CBasePlayer *)pPlayer );
		user.MakeReliable();
		UserMessageBegin( user, "KeyHintText" );
			WRITE_BYTE( 1 );	// one message
			WRITE_STRING( STRING(m_iszMessage) );
		MessageEnd();
	}
}
开发者ID:NEITMod,项目名称:Fixing_AI_In_Multiplayer,代码行数:36,代码来源:EnvHudHint.cpp

示例3: UTIL_GetNearestPlayer

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CEnvHudHint::InputHideHudHint( inputdata_t &inputdata )
{
	CBaseEntity *pPlayer = NULL;

	if ( inputdata.pActivator && inputdata.pActivator->IsPlayer() )
	{
		pPlayer = inputdata.pActivator;
	}
	else
	{
#ifdef HL2SB
		pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
		pPlayer = UTIL_GetLocalPlayer();
#endif
	}

	if ( pPlayer )
	{
		if ( !pPlayer || !pPlayer->IsNetClient() )
			return;

		CSingleUserRecipientFilter user( (CBasePlayer *)pPlayer );
		user.MakeReliable();
		UserMessageBegin( user, "KeyHintText" );
		WRITE_BYTE( 1 );	// one message
		WRITE_STRING( STRING(NULL_STRING) );
		MessageEnd();
	}
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:32,代码来源:EnvHudHint.cpp

示例4: user

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *player - 
//			effect - 
//			params - 
//-----------------------------------------------------------------------------
void CForceFeedback::StartEffect( CBasePlayer *player, FORCEFEEDBACK_t effect, const FFBaseParams_t& params )
{
	if ( !player )
	{
		return;
	}

	CSingleUserRecipientFilter user( player );

	UserMessageBegin( user, "ForceFeedback" );

		WRITE_BYTE( FFMSG_START ); // Reset effects
		WRITE_BYTE( effect );

		// encode direction as a byte
		int dir = (int)( ( params.m_flDirection / 360.0f ) * 255.0f );
		WRITE_BYTE( dir );

		// encode duration as a signed int
		int duration = (int)params.m_flDuration * 1000.0f;
		WRITE_LONG( duration );
		
		// encode gain as a byte
		byte gain = (byte)clamp( params.m_flGain * 255.0f, 0.0f, 255.0f );

		WRITE_BYTE( gain );
		WRITE_BYTE( params.m_nPriority );
		WRITE_BYTE( params.m_bSolo ? 1 : 0 );

	MessageEnd();
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:37,代码来源:forcefeedback.cpp

示例5: HapticMsg_MeleeContact

void HapticMsg_MeleeContact(CBasePlayer* pPlayer)
{
	CSingleUserRecipientFilter user(pPlayer);
	user.MakeReliable();
	UserMessageBegin(user,"HapMeleeContact");
	MessageEnd();
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:7,代码来源:haptic_msgs.cpp

示例6: switch

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pPlayer - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CGrubNugget::MyTouch( CBasePlayer *pPlayer )
{
	//int nHealthToGive = sk_grubnugget_health.GetFloat() * m_nDenomination;
	int nHealthToGive;
	switch (m_nDenomination)
	{
	case NUGGET_SMALL:
		nHealthToGive = sk_grubnugget_health_small.GetInt();
		break;
	case NUGGET_LARGE:
		nHealthToGive = sk_grubnugget_health_large.GetInt();
		break;
	default:
		nHealthToGive = sk_grubnugget_health_medium.GetInt();
	}

	// Attempt to give the player health
	if ( pPlayer->TakeHealth( nHealthToGive, DMG_GENERIC ) == 0 )
		return false;

	CSingleUserRecipientFilter user( pPlayer );
	user.MakeReliable();

	UserMessageBegin( user, "ItemPickup" );
	WRITE_STRING( GetClassname() );
	MessageEnd();

	CPASAttenuationFilter filter( pPlayer, "GrubNugget.Touch" );
	EmitSound( filter, pPlayer->entindex(), "GrubNugget.Touch" );

	UTIL_Remove( this );	

	return true;
}
开发者ID:xxauroraxx,项目名称:Source.Python,代码行数:39,代码来源:npc_antliongrub.cpp

示例7: user

void CLoot::SendLoot(CIN_Player *pPlayer)
{
	// No es un jugador.
	if ( !pPlayer )
		return;

	CSingleUserRecipientFilter user(pPlayer);
	user.MakeReliable();

	// Loot!!
	for ( int i = 1; i < LootItems.Count(); i++ )
	{
		// Este slot no tiene ningún objeto.
		if ( LootItems[i] == 0 || !LootItems[i] )
			continue;

		// Le enviamos la lista de objetos en este Loot.
		UserMessageBegin(user, "Loot");
			WRITE_SHORT(entindex());	// Se lo enviamos en cada objeto y nos evitamos hacer otro UserMessage
			WRITE_SHORT(i);				// ID en el array.
			WRITE_SHORT(LootItems[i]);	// ID del objeto.
		MessageEnd();
	}

	// Actualizamos el panel de Loot.
	pPlayer->ExecCommand("cl_update_loot 1");
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:27,代码来源:item_loot.cpp

示例8: GetCondition

//-----------------------------------------------------------------------------
// Purpose: Touch function
//-----------------------------------------------------------------------------
bool CTFBaseDMPowerup::MyTouch( CBasePlayer *pPlayer )
{
	bool bSuccess = false;

	CTFPlayer *pTFPlayer = dynamic_cast<CTFPlayer*>( pPlayer );
	if ( pTFPlayer && ValidTouch( pPlayer ) )
	{
		// Add the condition and duration from derived classes
		pTFPlayer->m_Shared.AddCond( GetCondition(), GetEffectDuration() );

		// Give full health
		SetHealth( GetMaxHealth() );

		CSingleUserRecipientFilter user( pPlayer );
		user.MakeReliable();

		UserMessageBegin( user, "ItemPickup" );
			WRITE_STRING( GetClassname() );
		MessageEnd();

		pPlayer->EmitSound( STRING( m_strPickupSound ) );

		bSuccess = true;
	}

	return bSuccess;
}
开发者ID:Deathreus,项目名称:TF2Classic,代码行数:30,代码来源:tf_basedmpowerup.cpp

示例9: FullClientUpdatePyNetworkClsByFilter

void FullClientUpdatePyNetworkClsByFilter( IRecipientFilter &filter )
{
	if( !SrcPySystem()->IsPythonRunning() )
		return;

	Assert(g_SetupNetworkTablesOnHold == false);

	// Send messages about each server class
	PyServerClass *p = g_pPyServerClassHead;
	while( p )
	{
		if( p->m_bFree ) {
			p = p->m_pPyNext;
			continue;
		}

		// Send message
		UserMessageBegin(filter, "PyNetworkCls");
		WRITE_BYTE(p->m_iType);
		WRITE_STRING(p->m_pNetworkName);
		WRITE_STRING(p->m_pNetworkedClass->m_pNetworkName);
		MessageEnd();

		p = p->m_pPyNext;
	}
}
开发者ID:detoxhby,项目名称:lambdawars,代码行数:26,代码来源:srcpy_server_class.cpp

示例10: UserMessageBegin

//=========================================================
// Deathnotice. 
//=========================================================
void CTeamplayRules::DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info )
{
	if ( m_DisableDeathMessages )
		return;

	CBaseEntity *pKiller = info.GetAttacker();
	if ( pVictim && pKiller && pKiller->GetFlags() & FL_CLIENT )
	{
		CBasePlayer *pk = (CBasePlayer*)pKiller;

		if ( pk )
		{
			if ( (pk != pVictim) && (PlayerRelationship( pVictim, pk ) == GR_TEAMMATE) )
			{
				CRelieableBroadcastRecipientFilter filter;

				// TODO we are sending this message twice ?? in BaseClass::DeathNotice too.
				UserMessageBegin( filter, "DeathMsg" );	
					WRITE_BYTE( pKiller->entindex() );		// the killer
					WRITE_BYTE( pVictim->entindex() );	// the victim
					WRITE_STRING( "teammate" );		// flag this as a teammate kill
				MessageEnd();
				return;
			}
		}
	}

	BaseClass::DeathNotice( pVictim, info );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:32,代码来源:teamplay_gamerules.cpp

示例11: GetResourceValue

//-----------------------------------------------------------------------------
// Purpose: If we're picked up by another pla`yer, give resources to that team
//-----------------------------------------------------------------------------
void CResourceChunk::ChunkTouch( CBaseEntity *pOther )
{
	if ( pOther->IsPlayer() || pOther->GetServerVehicle() )
	{
		// Give the team the resources
		int iAmountPerPlayer = ((CTFTeam *)pOther->GetTeam())->AddTeamResources( GetResourceValue(), TF_PLAYER_STAT_RESOURCES_ACQUIRED_FROM_CHUNKS );
		TFStats()->IncrementTeamStat( pOther->GetTeamNumber(), TF_TEAM_STAT_RESOURCE_CHUNKS_COLLECTED, GetResourceValue() );

		pOther->EmitSound( "ResourceChunk.Pickup" );

		// Tell the player
		CSingleUserRecipientFilter user( (CBasePlayer*)pOther );
		UserMessageBegin( user, "PickupRes" );
			WRITE_BYTE( iAmountPerPlayer ); 
		MessageEnd();

		// Tell our zone to remove this chunk from it's list
		if ( m_hZone )
		{
			m_hZone->RemoveChunk( this, false );
			m_hZone = NULL;
		}

		// Remove this chunk
		SetTouch( NULL );
		UTIL_Remove( this );
		return;
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:32,代码来源:resource_chunk.cpp

示例12: DispatchEffect

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWarsWeapon::MakeTracer( const Vector &vecTracerSrc, const trace_t &tr, int iTracerType )
{
#if 0
	const char* tracer = "ASWUTracer";
	//if (GetActiveASWWeapon())
	//	tracer = GetActiveASWWeapon()->GetUTracerType();
#ifdef CLIENT_DLL
	CEffectData data;
	data.m_vOrigin = tr.endpos;
	data.m_hEntity = this;
	//data.m_nMaterial = m_iDamageAttributeEffects;

	DispatchEffect( tracer, data );
#else
	CRecipientFilter filter;
	filter.AddAllPlayers();
	if (gpGlobals->maxClients > 1 && GetCommander())
	{ 
		filter.RemoveRecipient(GetCommander());
	}

	UserMessageBegin( filter, tracer );
		WRITE_SHORT( entindex() );
		WRITE_FLOAT( tr.endpos.x );
		WRITE_FLOAT( tr.endpos.y );
		WRITE_FLOAT( tr.endpos.z );
		//WRITE_SHORT( m_iDamageAttributeEffects );
	MessageEnd();
#endif
#else
#ifdef CLIENT_DLL
	ASWUTracer( GetOwner(), tr.endpos, m_vTracerColor );
#endif
#endif // 0
}
开发者ID:detoxhby,项目名称:lambdawars,代码行数:38,代码来源:wars_weapon_shared.cpp

示例13: switch

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFGameStats::SendStatsToPlayer( CTFPlayer *pPlayer, int iMsgType )
{
	PlayerStats_t &stats = m_aPlayerStats[pPlayer->entindex()];

	int iSendBits = stats.iStatsChangedBits;
	switch ( iMsgType )
	{
	case STATMSG_PLAYERDEATH:
	case STATMSG_PLAYERRESPAWN:
		break;
	case STATMSG_RESET:
		// this is a reset message, no need to send any stat values with it
		iSendBits = 0;
		break;
	case STATMSG_UPDATE:
		// if nothing changed, no need to send a message
		if ( iSendBits == 0 )
			return;
		break;
	case STATMSG_PLAYERSPAWN:
		// do a full update at player spawn
		for ( int i = TFSTAT_FIRST; i < TFSTAT_MAX; i++ )
		{
			iSendBits |= ( 1 << ( i - TFSTAT_FIRST ) );
		}
		break;
	default:
		Assert( false );
	}

	int iStat = TFSTAT_FIRST;
	CSingleUserRecipientFilter filter( pPlayer );
	UserMessageBegin( filter, "PlayerStatsUpdate" );
	WRITE_BYTE( pPlayer->GetPlayerClass()->GetClassIndex() );		// write the class
	WRITE_BYTE( iMsgType );											// type of message
	WRITE_LONG( iSendBits );										// write the bit mask of which stats follow in the message

	// write all the stats specified in the bit mask
	while ( iSendBits > 0 )
	{
		if ( iSendBits & 1 )
		{
			WRITE_LONG( stats.statsCurrentRound.m_iStat[iStat] );
		}
		iSendBits >>= 1;
		iStat ++;
	}
	MessageEnd();

	stats.iStatsChangedBits = 0;
	stats.m_flTimeLastSend = gpGlobals->curtime;

	if ( iMsgType == STATMSG_PLAYERDEATH )
	{
		// max sentry kills is different from other stats, it is a max value and can span player lives.  Reset it to zero so 
		// it doesn't get re-reported in the next life unless the sentry stays alive and gets more kills.
		pPlayer->SetMaxSentryKills( 0 );
		Event_MaxSentryKills( pPlayer, 0 );
	}
}
开发者ID:Navton,项目名称:TF2Classic,代码行数:63,代码来源:tf_gamestats.cpp

示例14: GetInPlayer

//=========================================================
// Se activa cuando el usuario toca el objeto.
//=========================================================
bool CSoda::MyTouch(CBasePlayer *pPlayer)
{
	// En modo Survival esto solo se puede usar desde el inventario.
	if ( g_pGameRules->IsMultiplayer() )
		return false;

	CIN_Player *pInPlayer = GetInPlayer(pPlayer);

	if ( !pPlayer )
		return false;

	if ( pInPlayer->TakeThirst(sk_soda.GetFloat()) != 0 )
	{
		CSingleUserRecipientFilter user(pInPlayer);
		user.MakeReliable();

		UserMessageBegin(user, "ItemPickup");
			WRITE_STRING(GetClassname());
		MessageEnd();

		CPASAttenuationFilter filter(pInPlayer, "Player.Drink");
		EmitSound(filter, entindex(), "Player.Drink");

		if ( g_pGameRules->ItemShouldRespawn(this) )
			Respawn();
		else
			Remove();

		return true;
	}

	return false;
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:36,代码来源:item_soda.cpp

示例15: user

void CTimer::DispatchResetMessage()
{
    CSingleUserRecipientFilter user(UTIL_GetLocalPlayer());
    user.MakeReliable();
    UserMessageBegin(user, "Timer_Reset");
    MessageEnd();
}
开发者ID:kirkelifson,项目名称:game,代码行数:7,代码来源:Timer.cpp


注:本文中的UserMessageBegin函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。