Thread: Script Help!
View Single Post
  #2  
Old 01-12-2012, 01:49 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

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

public class Mission : AMission
{

double initTime = 0.0;

public override void OnTickGame()
{

    if (Time.tickCounter() % 108000 == 18000) // 108000 = 60 min repeat. 18000 = 10 min delay.
    {
        GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice.mis");
        GamePlay.gpHUDLogCenter("The Battle of Britain is about to begin");

        Timeout(initTime += 600, () =>
        {
            GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Hawkinge");
        });
    }

    if (Time.tickCounter() % 108000 == 54000) // 108000 = 60 min repeat, 54000 = 30 min delay.
    {
        GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice1.mis");
        GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Lympne");

    }

    if (Time.tickCounter() % 108000 == 90000) // 60 min repeat, 50 min delay
    {
        GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice2.mis");
        GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Manston/Ramsgate");
    }
}

}
two problems
double initTime = 0.0;
Timeout(initTime += 600, () =>
made not much sense in OnTickGame. Every time the if clause is true initTime is reset to 0, and the message is send after 600 seconds.
initTime +=600 means initTime = initTime + 600;
if you like to send a message 600sec a mission is loaded you can use "Timeout(600, () =>" only
if you like to send a message 600sec a mission is loaded and then after the second time 1200sec then 1800sec you should place the double initTime = 0.0; outside to make it global in the class.

btw this makes more sense:
double initTime = 0.0;
Timeout(initTime, () =>
{
GamePlay.gpHUDLogCenter("Attention Reds");
});
Timeout(initTime += 5, () =>
{
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Hawkinge");
});
Timeout(initTime += 5, () =>
{
GamePlay.gpHUDLogCenter("Intercept them");
});
the first message is send directly the second 5 second later and the third 10 seconds, this is nessesary if you try for example these
GamePlay.gpHUDLogCenter("Attention Reds");
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Hawkinge");
GamePlay.gpHUDLogCenter("Intercept them");
only the last message "Intercept them" is shown.

and there was a
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Manston/Ramsgate");
}); <======= this is an error
}

Last edited by FG28_Kodiak; 01-12-2012 at 02:01 PM.
Reply With Quote