Thread: HudLog Question
View Single Post
  #2  
Old 05-15-2012, 10:34 PM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

I use this, slight variation to other methods, which are similar.

Note for arguments, like a set time you added, you need to place the value you want in the new object , note I set "timevalue"
Note: for screen hud messages, to avoid messages overwritting each other on screen to quickly, you add a timeout to delay the writtern message.

My version displays on screen and in log, so the message can be recalled by player.

Code:
ScreenMsg(-1, "MissionMessageToALL");
Timeout(2.0, () =>
{
   ScreenMsg(1, "RAF fly CAP between Calais and Dover");
   ScreenMsg(2, "LW meet a flight of Do17s 5000m over Calais in appr. {0} min.! Escort them", new object[] { timevalue });
 });

Code:
private void ScreenMsg(int army, string msg, params object[] args)
    {        
        List<Player> Consignees = new List<Player>();
        if (GamePlay.gpPlayer() != null)
            Consignees.Add(GamePlay.gpPlayer());
        if (GamePlay.gpRemotePlayers() != null)
            Consignees.AddRange(GamePlay.gpRemotePlayers());

        if (army == -1)
        {
            GamePlay.gpHUDLogCenter(null, msg, args);
            GamePlay.gpLogServer(null, msg, args);
        }
        else if (Consignees.Exists(item => item.Army() == army))
        {
            GamePlay.gpHUDLogCenter(Consignees.FindAll(item => item.Army() == army).ToArray(), msg, args);
            GamePlay.gpLogServer(Consignees.FindAll(item => item.Army() == army).ToArray(), msg, args);
        }
    }
Reply With Quote