View Single Post
  #1  
Old 04-23-2012, 05:48 AM
hc_wolf hc_wolf is offline
Approved Member
 
Join Date: Jul 2010
Posts: 439
Default OnAircraftCrashLanded trying to subtract flyable planes

I am having a bit of trouble getting this to subtract from the allowable flying planes on Crash land. It is usually easy when Actor is present. But how do I do it when player is null.

Below if a spitIIa crashlands then it should subtract 1 and the int allowedSpitIIas = 9;

The rest of the code works but it does not subtract from the allowedSpitIIas

Any idea?

Code:
    int allowedSpitIIas = 10;
    int currentSpitIIas = 0;
    int allowed109s = 10;
    int current109s = 0;



    public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
        Timeout(120, () =>
        { destroyPlane(aircraft); });

        Player player = null;
        if (player != null && player is AiAircraft)
        {
            
            switch ((player as AiAircraft).InternalTypeName())
            {

                case "bob:Aircraft.SpitfireMkIIa":
                    currentSpitIIas--;
                    allowedSpitIIas -= 1;
                    break;
                case "bob:Aircraft.Bf-109E-4":
                    currentSpitIIas--;
                    allowed109s -= 1;
                    break;

            }
        }

        if (aircraft.Player(0) != null)
        {
            for (int i = 0; i < aircraft.Places(); i++)
            {
                if (aircraft.Player(i) != null)
                {
                    player = aircraft.Player(i);
                    break;
                }
            }
            if (player != null)
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Looks like you are walking home...", new object[] { });

        }

    }
__________________
__________________
Win7, 64bit Ultra
Asus P8P67Pro MB
Intel i7-2600K
Coursair 16GB (4x 4GB), DDR3-1600MHz
Gainward Nvidia 580GTX 3GB DDR5
850-Watt Modular Power Supply
WIN7 and COD on Gskill SSD 240GB
40" Panasonic LCD
TrackIR5 +
Thrustmaster Warthog stick, throttle & pedals
Reply With Quote