View Single Post
  #2  
Old 06-13-2011, 03:31 AM
TheEnlightenedFlorist TheEnlightenedFlorist is offline
Approved Member
 
Join Date: May 2011
Location: SLC, Utah, USA
Posts: 143
Default

Removes abandoned planes.

Below is a small script that will load random missions at a specified interval. Change the strings "DEMissionPath" and "UKMissionPath" to wherever you're keeping your missions, then add the names of the missions to the List below that. Change the int below that to the interval you want them to be loaded in minutes.

Right now, the strings and Lists are populated with the values I'm using in my mission. You will have to change them

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

using System.Diagnostics;

public class Mission : AMission
{
    //paths to missions
    string DEMissionPath = "missions/Multi/Dogfight/OpDynamo/DEMissions/";
    string UKMissionPath = "missions/Multi/Dogfight/OpDynamo/UKMissions/";

    //missions to randomly select from
    List<string> DEMissions = new List<string> { "110_1.mis", "111_1.mis", "111_2.mis", "111_3.mis", "88_1.mis", "88_2.mis",
                                                    "88_3.mis"};
    List<string> UKMissions = new List<string> { "Hurri_1.mis", "Defiant_1.mis", "Hurri_2.mis" };

    //interval to load random missions. In minutes.
    int randInterval = 30;

    //timers for missions
    Stopwatch randTimer = new Stopwatch();

    public override void OnTickGame()
    {
        base.OnTickGame();

        //check mission timers
        if (randTimer.Elapsed.Minutes >= randInterval)
        {
            randTimer.Restart();
            Random rand = new Random();
            if (DEMissions.Count > 0)
                GamePlay.gpPostMissionLoad(DEMissionPath + DEMissions[rand.Next(0, DEMissions.Count)]);
            if (UKMissions.Count > 0)
                Timeout(5, () => { GamePlay.gpPostMissionLoad(UKMissionPath + UKMissions[rand.Next(0, UKMissions.Count)]); });
        }
    }
}
Reply With Quote