View Single Post
  #155  
Old 05-24-2011, 07:20 AM
klem's Avatar
klem klem is offline
Approved Member
 
Join Date: Nov 2007
Posts: 1,653
Default

Quote:
Originally Posted by Ataros View Post
This sample script made for fun disables player controls. Maybe someone can use it to disable AI controls for say 10 minutes before destroying AI

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

     public class Mission: maddox.game.AMission
     {
  	 / / Override the method that is invoked when some of the planes will take off ...
	 public override void OnAircraftTookOff (int missionNumber, string shortName, AiAircraft aircraft)
         {
             base.OnAircraftTookOff (missionNumber, shortName, aircraft); / / call the base method (you never know ...)
             if (GamePlay.gpPlayer ()! = null) / / check if we have a player.
             {
                 if (GamePlay.gpPlayer (). Place ()! = null) / / check that the player is sitting somewhere and not hanging out on the rag.
                 {
                     if (aircraft.Name (). Equals (GamePlay.gpPlayer (). Place (). Name ())) / / if the plane took off - a player, then ...
                     {
                         aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled); / / ... disables  elevators ...
                         aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled); / / ...  aileron ...
                         aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled); / / ...  rudder.
						 / / Have a nice flight!
                     }
                 }
             }
         }      
     }
More scripts here http://translate.google.com/translat...hp%3Ft%3D68369
Can anyone see what's wrong with the following? I get the first test message at about +45 seconds while still in the hangar (engine on or engine off), repeated every 20 seconds (which is strange) until about mission start +3mins but I never get the second test message or the messages that follow in the "if" statement:


//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
__________________
klem
56 Squadron RAF "Firebirds"
http://firebirds.2ndtaf.org.uk/



ASUS Sabertooth X58 /i7 950 @ 4GHz / 6Gb DDR3 1600 CAS8 / EVGA GTX570 GPU 1.28Gb superclocked / Crucial 128Gb SSD SATA III 6Gb/s, 355Mb-215Mb Read-Write / 850W PSU
Windows 7 64 bit Home Premium / Samsung 22" 226BW @ 1680 x 1050 / TrackIR4 with TrackIR5 software / Saitek X52 Pro & Rudders
Reply With Quote