## Engine
Class BroadcastHandler

source: C:\XIII\Engine\Classes\BroadcastHandler.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Info
             |
             +--Engine.BroadcastHandler

Direct Known Subclasses:None

class BroadcastHandler
extends Engine.Info

    //=============================================================================
    // BroadcastHandler
    //
    // Message broadcasting is delegated to BroadCastHandler by the GameInfo.
    // The BroadCastHandler handles both text messages (typed by a player) and
    // localized messages (which are identified by a LocalMessage class and id).
    // GameInfos produce localized messages using their DeathMessageClass and
    // GameMessageClass classes.
    //
    // This is a built-in Unreal class and it shouldn't be modified.
    //=============================================================================

Variables
`bool` | `bMuteSpectators` Whether spectators are allowed to speak.

Function Summary
`bool` | `AllowsBroadcast(Actor broadcaster, int Len)`
    /* Whether actor is allowed to broadcast messages now.
    */
`void` | `Broadcast(Actor Sender, string Msg, optional name)`
`void` | `BroadcastTeam(Controller Sender, string Msg, optional name)`
`void` | `BroadcastText(PlayerReplicationInfo SenderPRI, PlayerController Receiver, string Msg, optional name)`
`void` | `UpdateSentText()`

Source Code

    00001	//=============================================================================
    00002	// BroadcastHandler
    00003	//
    00004	// Message broadcasting is delegated to BroadCastHandler by the GameInfo.
    00005	// The BroadCastHandler handles both text messages (typed by a player) and
    00006	// localized messages (which are identified by a LocalMessage class and id).
    00007	// GameInfos produce localized messages using their DeathMessageClass and
    00008	// GameMessageClass classes.
    00009	//
    00010	// This is a built-in Unreal class and it shouldn't be modified.
    00011	//=============================================================================
    00012	class BroadcastHandler extends Info;
    00013
    00014	var	int			    SentText;
    00015	var config bool		bMuteSpectators;			// Whether spectators are allowed to speak.
    00016
    00017	function UpdateSentText()
    00018	{
    00019		SentText = 0;
    00020	}
    00021
    00022	/* Whether actor is allowed to broadcast messages now.
    00023	*/
    00024	function bool AllowsBroadcast( actor broadcaster, int Len )
    00025	{
    00026		if ( bMuteSpectators && (PlayerController(Broadcaster) != None)
    00027			&& PlayerController(Broadcaster).bOnlySpectator )
    00028			return false;
    00029
    00030		SentText += Len;
    00031		return (SentText < 260);
    00032	}
    00033
    00034
    00035	function BroadcastText( PlayerReplicationInfo SenderPRI, PlayerController Receiver, coerce string Msg, optional name Type )
    00036	{
    00037		Receiver.TeamMessage( SenderPRI, Msg, Type );
    00038	}
    00039
    00040	function BroadcastLocalized( Actor Sender, PlayerController Receiver, class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject )
    00041	{
    00042		Receiver.ReceiveLocalizedMessage( Message, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject );
    00043	}
    00044
    00045	function Broadcast( Actor Sender, coerce string Msg, optional name Type )
    00046	{
    00047		local PlayerController P;
    00048		local PlayerReplicationInfo PRI;
    00049
    00050		// see if allowed (limit to prevent spamming)
    00051		if ( !AllowsBroadcast(Sender, Len(Msg)) )
    00052			return;
    00053
    00054		if ( Pawn(Sender) != None )
    00055			PRI = Pawn(Sender).PlayerReplicationInfo;
    00056		else if ( Controller(Sender) != None )
    00057			PRI = Controller(Sender).PlayerReplicationInfo;
    00058
    00059		ForEach DynamicActors(class'PlayerController', P)
    00060			BroadcastText(PRI, P, Msg, Type);
    00061	}
    00062
    00063	function BroadcastTeam( Controller Sender, coerce string Msg, optional name Type )
    00064	{
    00065		local PlayerController P;
    00066
    00067		// see if allowed (limit to prevent spamming)
    00068		if ( !AllowsBroadcast(Sender, Len(Msg)) )
    00069			return;
    00070
    00071		ForEach DynamicActors(class'PlayerController', P)
    00072			if( P.PlayerReplicationInfo.Team == Sender.PlayerReplicationInfo.Team )
    00073				BroadcastText(Sender.PlayerReplicationInfo, P, Msg, Type);
    00074	}
    00075
    00076	/*
    00077	 Broadcast a localized message to all players.
    00078	 Most messages deal with 0 to 2 related PRIs.
    00079	 The LocalMessage class defines how the PRI's and optional actor are used.
    00080	*/
    00081	event AllowBroadcastLocalized( actor Sender, class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject )
    00082	{
    00083		local PlayerController P;
    00084
    00085		ForEach DynamicActors(class'PlayerController', P)
    00086			BroadcastLocalized(Sender, P, Message, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject);
    00087	}
    00088
    00089	defaultproperties
    00090	{
    00091	}

End Source Code