View Single Post
  #37  
Old 10-16-2011, 05:39 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Ok, i see couldn't work

this is the main block:

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

public class Mission : AMission
{


}
You must place your code between the two brackets { ... }

so you must place
public override void OnActorCreated(....)
{
.....
.....
}

and
public override void OnTickGame(...)
{
.....
.....
}
between the brackets.
Your fault was that you placed the OnActorCreated into the OntickGame and this is not allowed in C#.
Hint: Open your Clod Console and you will see error messages if anything goes wrong.

So should your code look like:
Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{

    public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
    {
        base.OnActorCreated(missionNumber, shortName, actor);

        if (actor is AiAircraft)
        {
            switch ((actor as AiAircraft).InternalTypeName())
            {

                case "bob:Aircraft.He-111P-2":

                    Timeout(600, () =>    // Time in Seconds
                         {
                             (actor as AiAircraft).Destroy();
                         });
                    break;
            }
        }
    }




    public override void OnTickGame()
    {

        // loads the 1st sub-mission in 10 min and repeates it every 60 min.
        if (Time.tickCounter() % 10800 == 180) // 108000 = 60 min repeat. 1800 = 10 min delay. 
        // pls. note!!! the 1st figure above must be always larger than 2nd!
        {
            GamePlay.gpPostMissionLoad("missions/Single/mission1.mis");

            // prints message on screen after mission load
            GamePlay.gpHUDLogCenter("Hello, world! Mission1.mis loaded!");

            // prints message on screen in 10 minutes
            double initTime = 0.0;
            Timeout(initTime += 600, () =>
            {
                GamePlay.gpHUDLogCenter("10 minutes into the 1st mission! Wow! It works!!!");
            });

            // prints message on screen in 5 minutes
            Timeout(initTime += 300, () =>
            {
                GamePlay.gpHUDLogCenter("Wholy s.. it works!!!");
            });

        }

        // loads the 2nd sub-mission, etc. the same way
        if (Time.tickCounter() % 10800 == 1000) //  108000 = 60 min repeat, 54000 = 30 min delay. 
        {
            GamePlay.gpPostMissionLoad("missions/Single/mission2.mis");
            GamePlay.gpHUDLogCenter("Mission2.mis loaded!");
            double initTime = 0.0;
            Timeout(initTime += 600, () =>
             {
                 GamePlay.gpHUDLogCenter("Mission2 10 min message!");
             });

            Timeout(initTime += 300, () =>
               {
                   GamePlay.gpHUDLogCenter("Mission2 15 min message!");
               });
        }

        // loads the 3rd sub-mission
        if (Time.tickCounter() % 10800 == 2000) // 60 min repeat, 50 min delay 
        {
            GamePlay.gpPostMissionLoad("missions/Multi/Single/mission3.mis");
            GamePlay.gpHUDLogCenter("Mission3.mis loaded!");

            double initTime = 0.0;
            Timeout(initTime += 600, () =>
            {
                GamePlay.gpHUDLogCenter("Mission3 10 min message!");
            });
            Timeout(initTime += 300, () =>
            {
                GamePlay.gpHUDLogCenter("Now it really works! You are a genius! Have fun!");
            });
        }
    }
}
btw i've not tested the script in Clod so may be there are other errors are present, but normaly it should work.
Reply With Quote