![]() |
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"); }); } } |
Code:
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 } |
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"); }); } } |
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 |
Thanks
Thanks.
|
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. |
Was feeling keen so ,
I have taken the liberty to take your layout and make it how i would do it. This is an example of how I would do it, others will do it differently and by know means the be all end of examples. The example i am attempting to show is input areas for easy programe mods. I have also added messages to armys(from the collections at 1C) note how the early part of the setup is for all the mission naming and timing triggers for those missions to load, this means you dont have to alter the core of the script(potential errors) This layout means you can use the script for all mission sets by altering the the main cs name, file paths and mission names. You will also probably need to add despawning code for excess planes, something everyone ends up adding. I again have modified others coding for our own design and need. by all means try this layout, modify as desired. Code:
|
All times are GMT. The time now is 03:54 PM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.