Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
guidelines:adding_message_to_gamebots [2012/02/08 16:59]
martin.cerny
guidelines:adding_message_to_gamebots [2012/02/08 21:27]
martin.cerny
Line 62: Line 62:
 <code> <code>
 static function SendNotifyMessage(){ static function SendNotifyMessage(){
- local Controller C; 
- local GBClientClass G; 
- local string message; 
- local WorldInfo worldInfo; 
-  
- worldInfo = class'WorldInfo'.static.GetWorldInfo(); 
- 
  message = "MYMESSAGE {StringParam bagr}";  message = "MYMESSAGE {StringParam bagr}";
  
- foreach worldInfo.AllControllers(class'Controller', C) +        SendMessageToAll("MYMESSAGE {StringParam bagr}"); 
- { +        SendMessageToAllBots("BOTMESSAGE {IntParam 23}"); 
- if( C.IsA('RemoteBot') ) +        SendMessageToAllControlConnections("CONTROLMESSAGE {FloatParam 1.5}");
-+
- RemoteBot(C).myConnection.SendLine(message); +
- +
-+
- +
-    if (GBGameInterface(worldInfo.Game).GetGameHandler().theControlServer != None) +
- { +
- for (G = GBGameInterface(worldInfo.Game).GetGameHandler().theControlServer.ChildListG != None; G = G.Next ) +
- { +
- G.SendLine(message); +
-+
- }+
  
 } }
  
 </code> </code>
-This method sends the message to all bot and control server connections.+This method sends the one message to all bot and control server connections, another only to all bots and yet another only to control connections. Note that while this method is quite simple it is good practice not to embed this in your action code, but keep it in the connection class so that the vocabulary of gamebots commands and messages is not scattered in many classes. 
 + 
 +Of course you might want to have a message that is sent for example only to the bot that triggered something. Than you need to get the bot object from the event and use it's connection.
  
 ====== Receiving commands from Pogamut ====== ====== Receiving commands from Pogamut ======
guidelines/adding_message_to_gamebots.txt · Last modified: 2012/02/08 21:34 by martin.cerny