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 10-29-2012, 01:48 PM
SG1_Lud's Avatar
SG1_Lud SG1_Lud is offline
Approved Member
 
Join Date: Jul 2010
Location: Spain
Posts: 376
Default C# Scripts: Referencing an AI aircraft.

Hi all:

Imagine we have the player aircraft inflight (A), and another one AI (B).

I can get the reference to the player aircraft (A) using:

Code:
//Get player aircraft
            cur_Plane = GamePlay.gpPlayer().Place() as AiAircraft;
Similarly, how can I get a reference to the other aircraft in flight (B) ?


Thanks.
Reply With Quote
  #2  
Old 10-29-2012, 03:36 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Depens on situation:

Normaly with gpActorByName in this example the Aircraft with name "0:BoB_RAF_F_111Sqn_Early.000"
Code:
AiAircraft aircraft = GamePlay.gpActorByName("0:BoB_RAF_F_111Sqn_Early.000") as AiAircraft;

if (aircraft != null)
{
    // code
}

Last edited by FG28_Kodiak; 10-29-2012 at 03:38 PM.
Reply With Quote
  #3  
Old 10-29-2012, 05:16 PM
SG1_Lud's Avatar
SG1_Lud SG1_Lud is offline
Approved Member
 
Join Date: Jul 2010
Location: Spain
Posts: 376
Default

Quote:
Originally Posted by FG28_Kodiak View Post
Depens on situation:

Normaly with gpActorByName in this example the Aircraft with name "0:BoB_RAF_F_111Sqn_Early.000"
Code:
AiAircraft aircraft = GamePlay.gpActorByName("0:BoB_RAF_F_111Sqn_Early.000") as AiAircraft;

if (aircraft != null)
{
    // code
}


Thank you Kodiak, that worked. My problem was that I was using the wrong name. In the .mis file I had "BoB_RAF_F_242Sqn_Early.00", but I see now: I have to use "0:BoB_RAF_F_242Sqn_Early.000".

So, if I got it ok,
BoB_RAF_F_242Sqn_Early.00 is a group and
n:BoB_RAF_F_242Sqn_Early.000 is an specific ac in that group
(where n = 0,1,,2 ...)

For the trailing added 0 I have no explanation



It is easier to get the name if I run the mission, right click ->view and hover the mouse over the ac of interest. Then a label appears with the exact name. I read this from you time ago and I had forgotten...

Thanks for pointing me in the right direction-

S!
Reply With Quote
  #4  
Old 10-30-2012, 08:56 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

the 0:, 1:, 2: are the missionNumbers of the Actor, so you must take care, if you load a new mission or create an actor via action and you like to reference one of the new actors you need the correct missionNumber.
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 09:48 AM.


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