PDA

View Full Version : Player's Aircraft


II./JG1_Krupinski
08-18-2011, 06:05 AM
How can I find out what aircraft the player is in when they spawn in?

OnPlaceEnter

Player interface...

I can't figure out how to determine it.

TheEnlightenedFlorist
08-18-2011, 06:22 AM
Are you looking for the type of aircraft the player is flying or the AiAircraft object?

In OnPlaceEnter(), actor can be cast as an AiAircraft. If you want the type of aircraft, cast actor to an AiAircraft and call InternalTypeName(). The string it gives you will look like this: "bob:Aircraft.Bf-109E-3".

FG28_Kodiak
08-18-2011, 08:57 AM
How can I find out what aircraft the player is in when they spawn in?

OnPlaceEnter

Player interface...

I can't figure out how to determine it.


public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);

GamePlay.gpLogServer(null, "{0} uses {1} Type {2}", new object[] { player.Name(), player.Place().Name(), (actor as AiAircraft).InternalTypeName() });
}


The example will shows following in chat with my callsign, Luftwaffe I/LG2 Nr.1 and a Ju-88A-1 as plane:
Kodiak uses 0:BoB_LW_LG2_I.000 Type bob:Aircraft.Ju-88A-1

player.Name() => player callsign
player.Place().Name() => 0:BoB_LW_LG2_I.000
(actor as AiAircraft).InternalTypeName() => bob:Aircraft.Ju-88A-1


You can get the actual playerplane with
AiAircraft airc1 = (AiAircraft)GamePlay.gpPlayer().Place();
also.

II./JG1_Krupinski
08-18-2011, 05:06 PM
Thanks,

That'll probably do it. I'll try when I get home.

On a side note: What's the difference between AiAircraft.TypeName() and AiAircraft.InternalTypeName()?

FG28_Kodiak
08-18-2011, 05:36 PM
TypedName() shows the tactical number of the plane.

II./JG1_Krupinski
08-18-2011, 09:34 PM
Thanks!