Code:
GamePlay.gpHUDLogCenter(null, "RAF fly CAP between Calais and Dover", new object[] {});
GamePlay.gpLogServer(null, "RAF fly CAP between Calais and Dover", new object[] {});
GamePlay.gpHUDLogCenter(null, "LW meet a flight of Do17s 5000m over Calais in appr. {0} min.! Escort them", new object[] {});
GamePlay.gpLogServer(null, "LW meet a flight of Do17s 5000m over Calais in appr. {0} min.! Escort them", new object[] {});
Ok first problem, you use null as destination, this means the message goes to all players. First parameter is a array of players the message should go to. So you need an array of all blue and a array of all red players.
So we first want all players:
there are two methods
GamePlay.gpPlayer(), on Singleplayer and player hosted Missions this is the player(host), on Dedicated Servers this is the server (it's usefull you like to write messages in the serverlog without showing it to others, for error messages etc.)
For the other players you need
GamePlay.gpRemotePlayers() this will get you a array with all players connected to the server could be null so you should test for null value (no players) before use it.
So if you want all players create a list and add the players to it:
Code:
List<Player> players = new List<Player>();
if (GamePlay.gpPlayer() != null)
players.Add(GamePlay.gpPlayer());
if (GamePlay.gpRemotePlayers() != null)
players.AddRange(GamePlay.gpRemotePlayers());
So now we have all, but we need the reds and the blues, the player object has the Army() method red players are member of the army 1 and blues are army 2.
to get the reds:
Code:
Player[] Reds = players.FindAll(item => item.Army() == 1).ToArray();
to get the blues
Code:
Player[] Blues = players.FindAll(item => item.Army() == 2).ToArray();
so now we have the two groups
before using them we must check if there i min one player in the group
so
Code:
if(Reds.Length > 0)
...
if(Blues.Length > 0)
...
so now we can send the message to the different groups:
Code:
if(Reds.Length > 0)
{
GamePlay.gpHUDLogCenter(Reds, "RAF fly CAP between Calais and Dover", new object[] {});
GamePlay.gpLogServer(Reds, "RAF fly CAP between Calais and Dover", new object[] {});
}
if(Blues.Length > 0)
{
GamePlay.gpHUDLogCenter(Blues, "LW meet a flight of Do17s 5000m over Calais in appr. {0} min.! Escort them", new object[] {});
GamePlay.gpLogServer(Blues, "LW meet a flight of Do17s 5000m over Calais in appr. {0} min.! Escort them", new object[] {});
}
Complete:
Code:
List<Player> players = new List<Player>();
if (GamePlay.gpPlayer() != null)
players.Add(GamePlay.gpPlayer());
if (GamePlay.gpRemotePlayers() != null)
players.AddRange(GamePlay.gpRemotePlayers());
Player[] Reds = players.FindAll(item => item.Army() == 1).ToArray();
Player[] Blues = players.FindAll(item => item.Army() == 2).ToArray();
if(Reds.Length > 0)
{
GamePlay.gpHUDLogCenter(Reds, "RAF fly CAP between Calais and Dover", new object[] {});
GamePlay.gpLogServer(Reds, "RAF fly CAP between Calais and Dover", new object[] {});
}
if(Blues.Length > 0)
{
GamePlay.gpHUDLogCenter(Blues, "LW meet a flight of Do17s 5000m over Calais in appr. {0} min.! Escort them", new object[] {});
GamePlay.gpLogServer(Blues, "LW meet a flight of Do17s 5000m over Calais in appr. {0} min.! Escort them", new object[] {});
}
So how to make easy to use methods is on you, learning by doing

or searching the forum

(there is already a thread about this)