Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-12-2012, 01:24 PM
king1hw king1hw is offline
Approved Member
 
Join Date: Jul 2010
Posts: 64
Default Script Help!

I was wondering if I changed this script right:

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

public class Mission : AMission
{

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");

double initTime = 0.0;
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");
});
}
}
Reply With Quote
  #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
  #3  
Old 01-12-2012, 02:15 PM
king1hw king1hw is offline
Approved Member
 
Join Date: Jul 2010
Posts: 64
Default Is this any better?

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

public class Mission : AMission
{

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");

double initTime = 0.0;
Timeout(initTime, () =>
{
GamePlay.gpHUDLogCenter("Attention Airbases");
});
Timeout(initTime += 5, () =>
{
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Hawkinge");
});
Timeout(initTime += 5, () =>
{
GamePlay.gpHUDLogCenter("Intercept them");
});
}

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");
});
}
}
Reply With Quote
  #4  
Old 01-12-2012, 02:25 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Yes but

GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Manston/Ramsgate");
}); <====== error

delete the needless
});
at the end of your script, its an error
Reply With Quote
  #5  
Old 01-12-2012, 02:35 PM
king1hw king1hw is offline
Approved Member
 
Join Date: Jul 2010
Posts: 64
Default Thanks

Thanks.
Reply With Quote
  #6  
Old 01-12-2012, 07:50 PM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

If I may interject some simple additions, I have some Basic experience from programming data loggers, but relatively new user to C# scripting myself however some rules apply to all programming all scripters should consider always to keep track of things.

Number 1
Document.

You should always date the lastest mods(keen programmers will even document mod changes in separate txt file)

For this sort of stuff, probably not essential, but do put a "Last Mod date" at the top of your script, maybe with any specific operational notes
ie
//Last update 12/01/2012

If you work with 2 or 3 others and pass the mis set about it is easy to get versions mixed up, a last mod date will help keep this error low.

Documentation of what the programe does helps, and helps development aswell.

2nd major consideration is repeat programming.
It can be far more effective to lower syntax errors by using commonly used components once and pull that item into code elsewhere by it's name.

For example the file path for missions.
if you do this at the start of the script,

string MissionPath = "missions/channelv6/BM1/";

When you call missions you only have to add the mis name
from this
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice2.mis");

to this
GamePlay.gpPostMissionLoad(MissionPath + "Practice2.mis");

The advantage is 2 fold, one, if you alter the folder naming you only have to do it once and two(more importantly) you are less likely to make simple syntax errors when adding multi missions to a larger script.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.