PDA

View Full Version : OnAircraftTookOff / OnAircraftLanded / OnAircraftCrashLanded


II./JG1_Krupinski
09-13-2011, 01:55 PM
Looks like the OnAircraftTookOff is now firing when a "player" takes off, which is great news.

Concerning OnAircraftLanded & OnAircraftCrashLanded, they will both fire off when i crash land. While I can work around this, it would make more sense that if a play crash lands, it doesn't fire the OnAircraftLanded too. Would be a lot cleaner and easier to manage. (coders will be able to depend on the method, rather than ever changing moving target of business rules as patches are released, the rules will be baked into the calls)

I haven't looked too terribly close, but it appears that OnAircraftTookOff, OnAircraftLanded, and OnAircraftCrashLanded are only working for "Player"? They don't seem to be fired off for AI aircraft? Does this sound accurate?

SNAFU
09-13-2011, 08:28 PM
I am currently trying to use the OnAircraftTookOff Methode, but it doesn´t seem to work on a dedicated server. Did you try a dedicated server and if so, what code did you use?

I tried the following:



public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftTookOff(missionNumber, shortName, aircraft);

if (GamePlay.gpPlayer().Place() != aircraft)
return;

switch (aircraft.Army())
{
case 1:
if (aircraft.Type() == AircraftType.Bomber || aircraft.Type().ToString().Equals("Bomber, DiveBomber")) //rote spieler
{
GamePlay.gpHUDLogCenter(new Player[] {GamePlay.gpPlayer() }, "Fly a reccon to LeHavre (AN4)");
}
else
{
GamePlay.gpHUDLogCenter(new Player[] {GamePlay.gpPlayer() }, "Cover our shipping south of Isle of White (AD17)");
}
break;

case 2:
if (aircraft.Type() == AircraftType.Bomber || aircraft.Type().ToString().Equals("Bomber, DiveBomber")) //blaue Spieler
{
GamePlay.gpHUDLogCenter(new Player[] {GamePlay.gpPlayer() }, "Attack britisch shipping south of Isle of White - AD17");
}
else
{
GamePlay.gpHUDLogCenter(new Player[] {GamePlay.gpPlayer() }, "Escort Ju87 from AC6 to AE15. Stukas leave AC6 after 15mins into mission!");
}
break;
}
}

II./JG1_Krupinski
09-13-2011, 09:29 PM
Haven't tried on dedi server yet. I assumed that it's working in non-dedicated that it would in a dedicated. Boy this will be a let down if it doesn't work on dedicated server.

As far as what code I'm using, your's looks like mine, except that I get a reference to the "player" by looping through the aircraft.Places() and finding the first "place" that isn't null - that being the player or "a" player.


for (int i = 0; i < aircraft.Places(); i++)
{
if (aircraft.Player(i) != null)
{
// TODO: Account for more than one player in an aircraft
player = aircraft.Player(i);
break;
}
}

if (player != null)
{
// do player specific code
//blah, blah. blah
}

FG28_Kodiak
09-13-2011, 09:34 PM
Cannot work on dedi:
GamePlay.gpPlayer()
doesn't work in multiplayer
you must use:

GamePlay.gpRemotePlayers (Array of player so you must find out which player is the correct one)

or

aircraft.Player(0) // is the pilot of Aircraft

so
if (aircraft.Player(0) == null) // no human pilot
return;

GamePlay.gpHUDLogCenter(new Player[] {aircraft.Player(0) }, "Fly a reccon to LeHavre (AN4)");

Sorry posted at same time
so use Krupinsky method above ;)

SNAFU
09-14-2011, 09:24 AM
Thanks, will try this. :cool:

II./JG1_Krupinski
09-14-2011, 03:31 PM
I confirmed last night that the OnAircraftTookOff event is indeed fired off, on a dedicated server.