Difference between revisions of "UTIL PlayerDecalTrace"

From Valve Developer Community
Jump to: navigation, search
m (link)
m
 
Line 1: Line 1:
{{wrongtitle|UTIL_PlayerDecalTrace}}
+
{{DISPLAYTITLE:UTIL_PlayerDecalTrace}}
 
UTIL_PlayerDecalTrace is a [[UTIL]] provided in the Source code for creating Player sprays.
 
UTIL_PlayerDecalTrace is a [[UTIL]] provided in the Source code for creating Player sprays.
  

Latest revision as of 07:28, 5 December 2011

UTIL_PlayerDecalTrace is a UTIL provided in the Source code for creating Player sprays.


Usage

/*
==============
UTIL_PlayerDecalTrace

A player is trying to apply his custom decal for the spray can.
Tell connected clients to display it, or use the default spray can decal
if the custom can't be loaded.
==============
*/
void UTIL_PlayerDecalTrace( trace_t *pTrace, int playernum )
{
	if (pTrace->fraction == 1.0)
		return;

	CBroadcastRecipientFilter filter;

	te->PlayerDecal( filter, 0.0,
		&pTrace->endpos, playernum, pTrace->m_pEnt->entindex() );
}


Examples

CBasePlayer *pPlayer = ToBasePlayer( GetOwnerEntity() );
if ( pPlayer )
{
   	int playernum = pPlayer->entindex();
	
	Vector forward;
	trace_t	tr;	

	AngleVectors( GetAbsAngles(), &forward );
	UTIL_TraceLine ( GetAbsOrigin(), GetAbsOrigin() + forward * 128, 
		MASK_SOLID_BRUSHONLY, pPlayer, COLLISION_GROUP_NONE, & tr);

	UTIL_PlayerDecalTrace( &tr, playernum );
}