UTIL SayTextFilter

From Valve Developer Community
Revision as of 13:25, 29 July 2021 by GamerDude27 (talk | contribs) (Cleanup)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.


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


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

    // Collect all visible players
    CRecipientFilter MyFilter;
    MyFilter.AddRecipientsByPVS( GetAbsOrigin() );

    // Tell visible players that I can see them
    CBasePlayer *pPlayer = UTIL_GetCommandClient();
    if ( pPlayer )
        char *pszCanSeeMsg = "";
        V_snprintf( pszCanSeeMsg, sizeof(pszCanSeeMsg), "%s can see you!", pPlayer->GetPlayerName() );
        UTIL_SayTextFilter( MyFilter, pszCanSeeMsg, UTIL_GetCommandClient() );