PDA

View Full Version : (Resolved) How to Broadcast?



AwesomeHighFive
09-10-2010, 02:39 AM
Thanks for your time.

I have a custom controller class with a custom pawn class.

I do

var myController c;

...

foreach AllActors(class'myController', c )
{
c.ClientMessage("Broadcasting.");
}

I receive no message.

Any idea why?

donamin
09-10-2010, 02:42 AM
try WorldInfo.Game.BroadCast(self, "BroadCasting");

AwesomeHighFive
09-10-2010, 03:06 AM
Thanks,

I actually modeled my broadcast off of the code in Worldinfo.BroadcastHandler.

The problem is that I need to broadcast data (sorry for the lack of clarity). The need for a message to display is just a debug state.

Any idea how to propagate data across all clients or perhaps, across a team specifically?

eurosat7
09-10-2010, 03:22 AM
untested: (I'm just getting into it)

Make your own MessageClass (extend LocalMessage) and a MyDataObject and call:
GameInfo .BroadcastHandler .BroadcastLocalized (Sender,PC, MessageClass,Switch, PRI1,PRI2,MyDataObject)

That will fire the following function on every client:
PlayerController .ReceiveLocalizedMessage (MessageClass,Switch, PRI1,PRI2,MyDataObject)

And that uses static MessageClass .ClientReceive (PC,Switch, PRI1,PRI2,MyDataObject)

Then MessageClass.GetString() will be used to call PlayerController.myHud.LocalizedMessage()

... really interresting, nay? ;)

Note:
There is also a GameInfo .BroadcastHandler .AllowBroadcastLocalizedTeam() - may fit better in your case.
ClientReceive would be a good place to process MyDataObject. (That's why I would extend LocalMessage)

Just thinking about extending MyDataObject from a Info. (ReplicationInfo might be to much Replication)

AwesomeHighFive
09-10-2010, 05:20 AM
Very interesting, and I appreciate your efforts in experimentation, but often I find that the simpler solution is the more effective.

Is there a "more standard" way to accomplish the simple goal of sending a variable to a group of players without needing it to be flagged as replicating?

Blade[UG]
09-10-2010, 01:16 PM
That IS how it's done. If this information is relevant to all clients, extend PlayerReplicationInfo or GameReplicationInfo, etc

AwesomeHighFive
09-14-2010, 01:18 PM
For anyone interested in the simplest way to do this:

function pushHelloWorldMessageToAllClients()

local Controller c;

...

foreach WorldInfo.AllControllers(class'Controller', c )
{
UTPlayerController(c).ClientMessage("Hello world");
}

The cast can be to anything really. I ended up using a custom controller class. Anything with ClientMessage will work.