Thread: NEed one scrip
View Single Post
  #2  
Old 03-10-2012, 12:46 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Code:
using System;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using maddox.GP;


public class Mission : AMission
{
    private bool IsDestroyable(AiAircraft aircraft)
    {
        bool Destroyable = true;

        //Check if actor is empty (no Player)

        if (aircraft.ExistCabin(0))
            for (int i = 0; i < aircraft.Places(); i++)
            {
                if (aircraft.Player(i) != null)
                {
                    Destroyable = false;
                    break;
                }
            }

        return Destroyable;
    }


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

        if(IsDestroyable(aircraft))
            Timeout(5, () =>
                {
                    aircraft.Destroy();
                });
    }


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

        if (IsDestroyable(aircraft))
            Timeout(5, () =>
            {
                aircraft.Destroy();
            });
    }
}
Reply With Quote