fearlessfrog
07-22-2011, 06:10 AM
I wrote a small c# script to display an IL2-style 'speed bar' in CoD. It's not great, but was fun to do. It's in this thread here:
http://simhq.com/forum/ubbthreads.php/topics/3344018/Is_it_possible_to_make_airspee.html
Since a few google searches led me to the people helping to explore scripting here, it seems proper to post back in-case it helps others.
using System;
using maddox.game;
using maddox.game.world;
using maddox.GP;
using System.Collections.Generic;
public class Mission : AMission
{
private double nextMsgTime = 0;
public override void OnTickGame()
{
{
base.OnTickGame();
if (Time.current() > nextMsgTime)
{
nextMsgTime = Time.current() + 3.0; // 3 ish seconds to next message
// Leave this in if you want to test a timer
//GamePlay.gpHUDLogCenter("Time elapsed (in seconds) = " + Time.current() +
// ", next message will be at " + nextMsgTime);
if (GamePlay.gpPlayer() != null) // check if we have a player.
{
if (GamePlay.gpPlayer().Place() != null)
{
Player me = GamePlay.gpPlayer();
Player[] all = { me };
AiActor where = me.Place();
Point3d pos = me.Place().Pos();
double height = ((pos.z + 62.5) / 306.5) * 1000;
AiAircraft aircraft = (GamePlay.gpPlayer().Place() as AiAircraft);
double ias = aircraft.getParameter(part.ParameterTypes.I_Veloci tyIAS, 0);
double altitude = aircraft.getParameter(part.ParameterTypes.I_Altitu de, 0);
double mag_compass = aircraft.getParameter(part.ParameterTypes.I_Magnet icCompass, 0);
double rep_compass = aircraft.getParameter(part.ParameterTypes.I_Repeat erCompass, 0);
double z_altitude = aircraft.getParameter(part.ParameterTypes.Z_Altitu deMSL, 0);
double z_ias = aircraft.getParameter(part.ParameterTypes.Z_Veloci tyTAS, 0);
double z_orientation = aircraft.getParameter(part.ParameterTypes.Z_Coordi nates, 0);
GamePlay.gpLogServer(all,
"Frogbar v0.1: HDG: " +
mag_compass.ToString("0") +
" ALT: " +
height.ToString("0") +
" SPD: " +
ias.ToString("0"), null);
}
}
}
}
}
}
Cheers!
http://simhq.com/forum/ubbthreads.php/topics/3344018/Is_it_possible_to_make_airspee.html
Since a few google searches led me to the people helping to explore scripting here, it seems proper to post back in-case it helps others.
using System;
using maddox.game;
using maddox.game.world;
using maddox.GP;
using System.Collections.Generic;
public class Mission : AMission
{
private double nextMsgTime = 0;
public override void OnTickGame()
{
{
base.OnTickGame();
if (Time.current() > nextMsgTime)
{
nextMsgTime = Time.current() + 3.0; // 3 ish seconds to next message
// Leave this in if you want to test a timer
//GamePlay.gpHUDLogCenter("Time elapsed (in seconds) = " + Time.current() +
// ", next message will be at " + nextMsgTime);
if (GamePlay.gpPlayer() != null) // check if we have a player.
{
if (GamePlay.gpPlayer().Place() != null)
{
Player me = GamePlay.gpPlayer();
Player[] all = { me };
AiActor where = me.Place();
Point3d pos = me.Place().Pos();
double height = ((pos.z + 62.5) / 306.5) * 1000;
AiAircraft aircraft = (GamePlay.gpPlayer().Place() as AiAircraft);
double ias = aircraft.getParameter(part.ParameterTypes.I_Veloci tyIAS, 0);
double altitude = aircraft.getParameter(part.ParameterTypes.I_Altitu de, 0);
double mag_compass = aircraft.getParameter(part.ParameterTypes.I_Magnet icCompass, 0);
double rep_compass = aircraft.getParameter(part.ParameterTypes.I_Repeat erCompass, 0);
double z_altitude = aircraft.getParameter(part.ParameterTypes.Z_Altitu deMSL, 0);
double z_ias = aircraft.getParameter(part.ParameterTypes.Z_Veloci tyTAS, 0);
double z_orientation = aircraft.getParameter(part.ParameterTypes.Z_Coordi nates, 0);
GamePlay.gpLogServer(all,
"Frogbar v0.1: HDG: " +
mag_compass.ToString("0") +
" ALT: " +
height.ToString("0") +
" SPD: " +
ias.ToString("0"), null);
}
}
}
}
}
}
Cheers!