View Single Post
  #18  
Old 05-20-2012, 06:50 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

You can check if a player is already in a plane

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

        int playercount = 0;
        
        if (actor != null && actor is AiAircraft)
        {
            AiAircraft aircraft = actor as AiAircraft;

            for (int i = 0; i < aircraft.Places(); i++)
            {
                if (aircraft.Player(i) != null)
                {
                    if (aircraft.Player(i) == player) playercount++;
                }
            }
        }


        if (playercount == 1) ..

    }
A Player can have two places in an aircraft (PlacePrimary() and PlaceSecondary()) so if playercount is > 1 (2 ) the player has changed his place in the aircraft.


or you check PlaceSecondary, PlaceSecondary is -1 if a player is 'new' in a plane, if not new PlaceSecondary gets the value of the last secondary place.
Code:
 if (player.PlaceSecondary() != -1)
            ..

Last edited by FG28_Kodiak; 05-20-2012 at 07:42 PM.
Reply With Quote