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 03-07-2012, 06:26 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default sayMessageTo script help

Trying to send radio voice (saygroup) messages to each person in a given army. Code has no compile errors but doesn't voice to players? Any help appreciated.

Code:
    private void sayMessageTo(int army, string msg)
    {   // send a speech message to all players in specified army (1=red; 2=blue)
        foreach (AiAirGroup g in GamePlay.gpAirGroups(army))
        {
            bool SaidToGroup = false;
            foreach (AiAircraft a in g.candidates())
            {
                if (SaidToGroup == true) return; // speech already said to group
                SaidToGroup = true;
                a.SayToGroup(a.AirGroup(), "Received_and_understood_Villa_Leader");  // for testing only
                //a.SayToGroup(a.AirGroup(), msg);
            }
        }
    }
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash.

Get the latest COD Team Fusion patch info HERE

Last edited by salmo; 03-07-2012 at 06:28 AM.
Reply With Quote
  #2  
Old 03-07-2012, 06:58 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Your error:
if (SaidToGroup == true) return;
you leaving the method, but i think you will only leave the foreach, so you must use:
if (SaidToGroup == true) break;

and g.candidates() returns AiAirGroup[] so you should use GetItems() to get the Actors.

Corrected code:
Code:
private void sayMessageTo(int army, string msg)
    {   // send a speech message to all players in specified army (1=red; 2=blue)
        foreach (AiAirGroup g in GamePlay.gpAirGroups(army))
        {
            bool SaidToGroup = false;
            foreach (AiActor a in g.GetItems())
            {
                if (SaidToGroup == true) break; // speech already said to group
                SaidToGroup = true;
                (a as AiAircraft).SayToGroup((a as AiAircraft).AirGroup(), "Ready_for_takeoff");  // for testing only
                //a.SayToGroup(a.AirGroup(), msg);
            }
        }
    }

Last edited by FG28_Kodiak; 03-07-2012 at 07:02 AM.
Reply With Quote
  #3  
Old 03-07-2012, 07:06 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default

Thanks Kodiak. I altered the script (below x 2) to eliminate if/break issues. Still doesn't work though It's as though the GamePlay.gpAirGroups(army) call is not returning any valid aircraft?

Code:
        private void sayMessageTo(int army, string msg)
    {   // send a speech message to all players in specified army (1=red; 2=blue)
        foreach (AiAircraft a in GamePlay.gpAirGroups(army))
        {
            a.SayToGroup(a.AirGroup(), "Nice_shot");  // for testing

        }
    }
Code:
        private void sayMessageTo(int army, string msg)
    {   // send a speech message to all players in specified army (1=red; 2=blue)
        sendScreenMessageTo(1, "saymessage", null);  // testing
        foreach (AiAircraft a in GamePlay.gpAirGroups(1))
        {
            a.SayToGroup(a.AirGroup(), "Nice_shot");

        }
        foreach (AiAircraft a in GamePlay.gpAirGroups(2))
        {
            a.SayToGroup(a.AirGroup(), "Nice_shot");

        }
    }
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash.

Get the latest COD Team Fusion patch info HERE

Last edited by salmo; 03-07-2012 at 07:14 AM.
Reply With Quote
  #4  
Old 03-07-2012, 07:11 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

try my correction above, it should work.

GamePlay.gpAirGroups(army) returns AiAirGroup[]
AiAirGroup.Candidates returns AiAirGroup[]

You need an Actor (AiAircraft) for saytogroup
so you should use
AiAirGroup.GetItems() returns AiActor[]

you get no error because AiAirGroup is also an Actor, but in these case the wrong one.

Last edited by FG28_Kodiak; 03-07-2012 at 07:15 AM.
Reply With Quote
  #5  
Old 03-07-2012, 07:39 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default

Yes, above example works. Thankyou again Kodiak
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash.

Get the latest COD Team Fusion patch info HERE
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 03:59 AM.


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