GamePlay.gpGetAction Question
Hello All,
First of all, thank you for this great forum and all the information we can find. As it is my first post, I take the occasion to say hello to all the COD fan.
My question is regarding this script :
AiAction action = GamePlay.gpGetAction("XXXXXXX");
if (action != null)
{
action.Do();
}
My goal is to constantly test the flight level of an aircraft (I have the flight level thanks to a OnTickGame function and it works fine).
As I don't know the name of the aircraft (the XXXX in the script above), I use the following script :
AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
It works fine for a OnTrigger() function but it doesn't for a OnTickGame function because missionNumber and shortName do not exist in the OnTickGame context.
So, either I use the exact name XXXXX used by COD mission but I can't find it in the mission file (I tried many name indicated in this file but nothing seems to work) or I use the script above with missionNumber and shortName but it doesn't work in the OnTickGame function.
Have you any Idea of How I can manage this ?
I must say the I search a long time on internet and I tried many thing but nothing works. I am not a specialist of C# and script and I problably make a mistake but I can't see where.
So the full script is something like this :
using System;
using maddox.game;
using maddox.game.world;
public class Mission : maddox.game.AMission
{
double I_Altitude;
public override void OnTickGame()
{
base.OnTickGame();
if (Time.tickCounter() % 30 == 1)
{
AiAircraft curPlane = GamePlay.gpPlayer().Place() as AiAircraft;
if (curPlane != null)
{
I_Altitude = curPlane.getParameter(part.ParameterTypes.I_Altitu de, -1);
double dtime = Time.current();
GamePlay.gpHUDLogCenter(" ALT: " + I_Altitude.ToString("0.00"));
if (I_Altitude > 400)
{
GamePlay.gpHUDLogCenter("above 400");
AiAction action = GamePlay.gpGetAction(maddox.game.ActorName.Full(mi ssionNumber, shortName));
if (action != null)
{
action.Do();
}
}
}
}
}
}
Last point, I would like to thank all the people that post script on internet. As mentioned, I am not a great script maker and I try to understand and reuse existing code. The code above is a made of different script that I found on internet. Thanks to all the guy that made them.
Frantic
|