Difference between revisions of "UTIL SayTextFilter"

From Valve Developer Community
Jump to: navigation, search
(Created page.)
 
m (Category.)
Line 19: Line 19:
 
  UTIL_SayTextFilter(MyFilter, CanSeeMsg, UTIL_GetCommandClient());
 
  UTIL_SayTextFilter(MyFilter, CanSeeMsg, UTIL_GetCommandClient());
 
  }
 
  }
 +
 +
[[Category:UTIL]]

Revision as of 22:58, 22 July 2021

A UTIL function that sends a message to players that match a filter. This function is the base function for the other UTIL_Say functions.

Usage

void UTIL_SayTextFilter(IRecipientFilter& filter, const char *pText, CBasePlayer *pPlayer, bool bChat)

Example

The code tells all players visible from an entity that it can see them.

// Collect all visible players
CRecipientFilter MyFilter;
MyFilter.AddRecipientsByPVS( GetAbsOrigin() );
MyFilter.MakeReliable();
// Tell visible players that I can see them.
CBasePlayer *player = UTIL_GetCommandClient();
if (player) {
	char* CanSeeMsg="";
	V_snprintf(CanSeeMsg, sizeof(CanSeeMsg), "%s can see you!", player->GetPlayerName());
	UTIL_SayTextFilter(MyFilter, CanSeeMsg, UTIL_GetCommandClient());
}