![]() |
Flashman,
OnTickGame() is called 30 times in second and every second, so your script 30 times in second schedules a mission loading, and repeats that endlessly. You are abusing your computer :) Put this into Init(), not in OnTickGame(). |
Quote:
Hi Zaltys, Thanks for your help, however please excuse my ignorance. I have tried putting Init() in carious places but I can't work it out. ANy chance you can edit my previous file and put it in the correct place so I can see how it should work? I really have no idea what im doing...... Thanks |
PHP Code:
|
Quote:
I had worked out I was missing the (battle, mission....) part but it still didn't work. it was the base.init part that made it function correctly, and I wouldn't have a clue about that. Cheers! |
Quote:
//SEND MESSAGE TO PLAYER WHEN THEY HAVE TAKEN OFF public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftTookOff(missionNumber, shortName, aircraft); GamePlay.gpHUDLogCenter("Takeoff messages start."); //Test/debug Message if (aircraft.Name() == GamePlay.gpPlayer().Place().Name()) // if the plane took off - a player, then ... { GamePlay.gpHUDLogCenter("Switch section reached"); //Test/debug Message switch (aircraft.Army()) { case 1: if ((aircraft.Type() == AircraftType.Bomber) || (aircraft.Type() == AircraftType.DiveBomber)) // if Bomber or Divebomber { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Remember, Get Organised! Attack briefed targets!"); } else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Organise Escorts and protect Convoy moving from Beachy Head to the Thames Estuary!"); } break; case 2: if ((aircraft.Type() == AircraftType.Bomber) || (aircraft.Type() == AircraftType.DiveBomber)) // if Bomber or Divebomber { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Remember, Get Organised and attack briefed Targets!"); } else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Remember, Get Organised and protect our bombers by Escort or Frei Jagd!"); } break; } } } //end public override void OnAircraftTookOff |
Hi,
I have never tried scripting for Clod, but as a C# programer, I'm going to make an educated guess: Try changing this line: if (aircraft.Name() == GamePlay.gpPlayer().Place().Name() ) for this one: if ( aircraft.Name().Equals(GamePlay.gpPlayer().Place().Name()) ) I'm not sure of this because I don't know the types of the objects involved in the comparison (strings?), but try it anyway. (Check this for more info about why: C# Value Type vs Reference Type) Also you should check that aircraft is not null, and that GamePlay.gpPlayer().Place() is not null, for security reasons in order to avoid NullReference exceptions. |
klem,
OnAircraftTookOff(() does not currently work for planes spawned at BirthPlaces. It should work for FMB planes with waypoints. I guess, you get first message showed because you have AI taking off. |
Instead of;
Code:
if (aircraft.Name() == GamePlay.gpPlayer().Place().Name()) Code:
if (aircraft == GamePlay.gpPlayer().Place()) |
Quote:
It was for MP and for a BirthPlace so a double fail :( btw I had it report aircraft.Name() and GamePlay.gpPlayer().Place().Name() and they were the same string so 'If == ' should have worked ok. |
Quote:
public override void OnTrigger(int missionNumber, string shortName, bool active) { //call base classes OnTrigger method. base.OnTrigger(missionNumber, shortName, active); GamePlay.gpHUDLogCenter("shortname = " + shortName); //if the trigger that was called is the trigger that we're looking for if (shortName.Equals("AttackConvoy2Delay1")) { AiAction action = GamePlay.gpGetAction("AttackConvoy2_1") ; if (action != null) { action.Do(); } } } The '&& active' didn't work because: 1. It seems it should be + not && 2. You can see I tested for the shortname and of course ("AttackConvoy2Delay1" + active) isn't equal to "AttackConvoy2Delay1". I don't know what 'active' comes back as but it would make the strings unequal. Also, I put { } around the if(action != null) output as { action.Do(); } although that may not havebeen necessary. Anyway it works ! Thanks for the help TheEnlightenedFlorist. |
All times are GMT. The time now is 03:09 PM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.