Official Fulqrum Publishing forum

Official Fulqrum Publishing forum (http://forum.fulqrumpublishing.com/index.php)
-   FMB, Mission & Campaign builder Discussions (http://forum.fulqrumpublishing.com/forumdisplay.php?f=203)
-   -   HUD Log Script? (http://forum.fulqrumpublishing.com/showthread.php?t=32895)

king1hw 06-28-2012 03:10 PM

HUD Log Script?
 
Would this work?

using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{

public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("Trigger2All".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Trigger2All");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;

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 (("ScoreBlue50".Equals(shortName) && active) && (MissionTimer1M1.Elapsed.Minutes <= 58) ) //Trigger 1 Message
{
GamePlay.gpHUDLogCenter("The LW succeeded and inflicted heavy damage on Port of Dover");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("ScoreRed51".Equals(shortName) && active) //Trigger 1 Message
{
GamePlay.gpHUDLogCenter("The RAF inflicted heavy losses on the LW bombers");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("ScoreRed49".Equals(shortName) && active) //Trigger 2 Message
{
GamePlay.gpHUDLogCenter("The RAF inflicted heavy losses on the LW bombers");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if (("Trigger2ALL".Equals(shortName) && active) && (Reds.Length > 0) ) //Trigger 2 Message
{
GamePlay.gpHUDLogCenter(Reds,"German build-up over Calais plotted, heading N!", new object[] { }, 3);
GamePlay.gpGetTrigger(shortName).Enable = false;

}

}

public override void OnTickGame()
{
if (Time.tickCounter() % 864000 == 63000) // 864000 = 8 hour repeat, 63000 = 35 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940_v10/Missionen/Mission2.mis");

if (Reds.Length > 0)
{
GamePlay.gpHUDLogCenter(Reds, "RAF- Fly CAP between Calais and Dover", new object[] { }, 5);
GamePlay.gpLogServer(Reds, "RAF- Fly CAP between Calais and Dover", new object[] { });
}
if (Blues.Length > 0)
{
GamePlay.gpHUDLogCenter(Blues, "LW- Meet a flight of HE111's 5000m over Calais. Escort them to Dover!", new object[] { }, 5);
GamePlay.gpLogServer(Blues, "LW- Meet a flight of HE111's 5000m over Calais.\n In appr. 10 minutes into mission! Escort them to Dover!", new object[] { });
}
}
}

//Section 4 : AI remove

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);
if (actor is AiGroundActor)
Timeout(3599, () =>
{
if (actor != null)
{ (actor as AiGroundActor).Destroy(); }
}
);
}

}

FG28_Kodiak 06-28-2012 04:29 PM

No it would not to many errors :rolleyes:


I ve corrected your script:
Code:

using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{

    public Player[] AllPlayers()
    {
        List<Player> players = new List<Player>();

        if (!GamePlay.gpIsServerDedicated())
            if (GamePlay.gpPlayer() != null)
                players.Add(GamePlay.gpPlayer());

        if (GamePlay.gpRemotePlayers() != null)
            players.AddRange(GamePlay.gpRemotePlayers());

        return players.ToArray();
    }


    public Player[] Red()
    {
        List<Player> players = new List<Player>();

        if (AllPlayers() != null)
        {
            players.AddRange(AllPlayers());
            return players.FindAll(item => item.Army() == 1).ToArray();
        }
        return null;
    }


    public Player[] Blue()
    {
        List<Player> players = new List<Player>();

        if (AllPlayers() != null)
        {
            players.AddRange(AllPlayers());
            return players.FindAll(item => item.Army() == 2).ToArray();
        }
        return null;
    }


    public void SendChatMessageTo(Player[] players, string msg, params object[] args)
    {
        if (players == null) return;

        GamePlay.gpLogServer(players, msg, args);
    }


    public void SendScreenMessageTo(Player[] players, string msg, params object[] args)
    {
        if (players == null) return;

        GamePlay.gpHUDLogCenter(players, msg, args);
    }



    public override void OnTrigger(int missionNumber, string shortName, bool active)
    {
        base.OnTrigger(missionNumber, shortName, active);

        if ("Trigger2All".Equals(shortName) && active)
        {
            AiAction action = GamePlay.gpGetAction("Trigger2All");
            if (action != null)
            {
                action.Do();
            }
            GamePlay.gpGetTrigger(shortName).Enable = false;
        }

        if ("ScoreBlue50".Equals(shortName) && active) //Trigger 1 Message
        {
            GamePlay.gpHUDLogCenter("The LW succeeded and inflicted heavy damage on Port of Dover");
            GamePlay.gpGetTrigger(shortName).Enable = false;
        }

        if ("ScoreRed51".Equals(shortName) && active) //Trigger 1 Message
        {
            GamePlay.gpHUDLogCenter("The RAF inflicted heavy losses on the LW bombers");
            GamePlay.gpGetTrigger(shortName).Enable = false;
        }

        if ("ScoreRed49".Equals(shortName) && active) //Trigger 2 Message
        {
            GamePlay.gpHUDLogCenter("The RAF inflicted heavy losses on the LW bombers");
            GamePlay.gpGetTrigger(shortName).Enable = false;
        }

        if ("Trigger2ALL".Equals(shortName) && active) //Trigger 2 Message
        {
            SendScreenMessageTo(Red(), "German build-up over Calais plotted, heading N!");
            GamePlay.gpGetTrigger(shortName).Enable = false;
        }

    }

    public override void OnTickGame()
    {
        if (Time.tickCounter()%864000 == 63000) // 864000 = 8 hour repeat, 63000 = 35 min delay.
        {
            GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940_v10/Missionen/Mission2.mis");

            SendScreenMessageTo(Red(), "RAF- Fly CAP between Calais and Dover");
            SendChatMessageTo(Red(), "RAF- Fly CAP between Calais and Dover");

            SendScreenMessageTo(Blue(), "LW- Meet a flight of HE111's 5000m over Calais. Escort them to Dover!");
            SendChatMessageTo(Blue(), "LW- Meet a flight of HE111's 5000m over Calais. Escort them to Dover!");
        }

    }

    //Section 4 : AI remove

    public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
    {
        base.OnActorCreated(missionNumber, shortName, actor);
        if (actor is AiGroundActor)
            Timeout(3599, () =>
                              {
                                  if (actor != null)
                                  {
                                      (actor as AiGroundActor).Destroy();
                                  }
                              }
                );
    }

}

Explanations:

with AllPlayers() you get all players in the game.
with Red() only the red players.
with Blue() only the blue.

if created two method
public void SendChatMessageTo(Player[] players, string msg, params object[] args)
and
public void SendScreenMessageTo(Player[] players, string msg, params object[] args)

the first sends the message to the chat window and the second to the screen, to use them use:

to all players in game
SendChatMessageTo(AllPlayers(), "Your Message");
to the red side
SendChatMessageTo(Red(), "Your Message");
to the blue side:
SendChatMessageTo(Blue(), "Your Message");

if you would like to show variables, points for example you can use:
int redpoints = 50;
SendChatMessageTo(Red(), "Red Side gets {0} points", redpoints);

btw in the string {0} is a placeholder for the first variable, {1} for the second, {2} for the third and so on..
you should take care that the number of placeholders and the number of the variables are the same.
For example this will work:
SendChatMessageTo(Red(), "Red Side gets {0}/{1} points", redpoints, overallPoints);

this will also work, but the value of the second variable is not shown
SendChatMessageTo(Red(), "Red Side gets {0} points", redpoints, overallPoints);

but this will get an error:
SendChatMessageTo(Red(), "Red Side gets {0}/{1} points", redpoints);

hope it helps ;)


All times are GMT. The time now is 06:32 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.