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
  #11  
Old 10-03-2011, 09:17 AM
Gromic's Avatar
Gromic Gromic is offline
Approved Member
 
Join Date: Aug 2010
Posts: 77
Default

Hi chaps,

figured I'd crash and burn on my first attempt. I'd like to mention the fact that I have virtually no experience with C# and am more or less learning this stuff via copy and paste

Kodiak, I dropped your script from post#2 (trying to keep it simple) into one of my missions, pressed compile and was greeted with numerous error messages that I can't wrap my head around atm. It is the only script within the mission.

-----------------------------------------------------------------------
c:\Users\Gromic\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\BOB\BOB1.cs(1,13): error CS1518: Klasse, Delegat, Enumeration, Schnittstelle oder Struktur erwartet.

c:\Users\Gromic\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\BOB\BOB1.cs(1,67): error CS1001: Bezeichner erwartet

c:\Users\Gromic\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\BOB\BOB1.cs(1,69): error CS1518: Klasse, Delegat, Enumeration, Schnittstelle oder Struktur erwartet.

c:\Users\Gromic\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\BOB\BOB1.cs(14,44): error CS1518: Klasse, Delegat, Enumeration, Schnittstelle oder Struktur erwartet.

c:\Users\Gromic\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\BOB\BOB1.cs(22,13): error CS1022: Typ- oder Namespacedefinition oder Dateiende erwartet.
-----------------------------------------------------------------------

I figured that the initial script was in raw form so I ammended line 9 from:
GamePlay.gpHUDLogCenter(null, msg, parms);

to

GamePlay.gpHUDLogCenter("en", "msg red", null );

Help!

And let me be so kind as to say in advance, thank you for all that you, and others, have done with scripting. Especially with the lack of documentation from 1C.

Cheers

Gromic
__________________
I5-750 @ 3,8GHz / MSI P55-GD65 / MSI GTX570 Twin Frozr II / 4x2GB G.Skill 1600MHz / Corsair TX650 PSU / RAID 0 2x640GB WD Black
W7 Pro x64 SP1 / MS FFB2 +Saitek X45 / Freetrack + NP Clip Pro + PS3 Eye / Samsung BX2450 24" HDMI LED
Reply With Quote
  #12  
Old 10-03-2011, 09:28 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Seems you have set a wrong or missing Bracket. Can you show me your complete code please.

Deutsche Fehlermeldungen mir deucht ich hab nen Landsmann (oder Umgebung) vor mir


GamePlay.gpHUDLogCenter("en", "msg red", null );
couldn't work
gpHUDLogCenter needs in this case a array of players as first argument (or null - null meens send message to all)




Added a example script

Last edited by FG28_Kodiak; 10-12-2011 at 12:00 PM.
Reply With Quote
  #13  
Old 10-03-2011, 11:04 AM
Gromic's Avatar
Gromic Gromic is offline
Approved Member
 
Join Date: Aug 2010
Posts: 77
Default

Moin Kodiak

This is the code I was using. It's yours from post 2 of this thread.

Code:
    private void sendScreenMessageTo(int army, string msg, object[] parms)
    {
        if (army != -1)
        {
            //Singleplayer (for Testing)
            if (GamePlay.gpRemotePlayers() == null || GamePlay.gpRemotePlayers().Length <= 0)
            {
                if (GamePlay.gpPlayer() != null && GamePlay.gpPlayer().Army() == army)
                    GamePlay.gpHUDLogCenter(null, msg, parms);

            }
            else // Multiplayer
            {
                List<Player> Players = new List<Player>();

                foreach (Player p in GamePlay.gpRemotePlayers())
                {
                    if (p.Army() == army)
                        Players.Add(p);
                }
                GamePlay.gpHUDLogCenter(Players.ToArray(), msg, parms);
            }
        }
        else GamePlay.gpHUDLogCenter(null, msg, parms);
    }


    private void sendChatMessageTo(int army, string msg, object[] parms)
    {
        if (army != -1)
        {
            //Singleplayer (for Testing)
            if (GamePlay.gpRemotePlayers() == null || GamePlay.gpRemotePlayers().Length <= 0)
            {
                if (GamePlay.gpPlayer() != null && GamePlay.gpPlayer().Army() == army)
                    GamePlay.gpLogServer(null, msg, parms);

            }
            else // Multiplayer
            {
                List<Player> Players = new List<Player>();

                foreach (Player p in GamePlay.gpRemotePlayers())
                {
                    if (p.Army() == army)
                        Players.Add(p);
                }
                GamePlay.gpLogServer(Players.ToArray(), msg, parms);
            }
        }
        else GamePlay.gpLogServer(null, msg, parms);
    }
I don't see any missing brackets but then my eyes aren't what they used to be. Thanks for the example script. I'll check it out as soon as I can.

P.S. Landsmann ist richtig. Dürfte vermutlich nicht mal so weit von dir sein da "Bayern" auch bei mir im Perso steht. Nähe Aschaffenburg. Schöne Grüße und danke für alles was du bisher für die Community getan hast!
__________________
I5-750 @ 3,8GHz / MSI P55-GD65 / MSI GTX570 Twin Frozr II / 4x2GB G.Skill 1600MHz / Corsair TX650 PSU / RAID 0 2x640GB WD Black
W7 Pro x64 SP1 / MS FFB2 +Saitek X45 / Freetrack + NP Clip Pro + PS3 Eye / Samsung BX2450 24" HDMI LED
Reply With Quote
  #14  
Old 10-03-2011, 11:11 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Ah ok now i know the error:
These lines you copy are useless, without

using System;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;


public class Mission : AMission
{

// place the code here




}
Reply With Quote
  #15  
Old 10-03-2011, 08:35 PM
Gromic's Avatar
Gromic Gromic is offline
Approved Member
 
Join Date: Aug 2010
Posts: 77
Default

Right, now I really look foolish. I'd forgotten to add the librarys.

We've got a chap in our squad that works with C# professionally and he sacrificed some time and helped me with a script, using the ones that you've so kindly donated as a basis to go on.

He's come up with a script that works perfectly. We have it running on our dedicated server. Here's an excerpt from one of our sub-missions.

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

public class Mission : AMission
{
    private const int All = -1;
    private const int Allies = 1;
    private const int Axis = 2;

    public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);

        SendScreenMessageTo(All, "Welcome Everyone");
        SendScreenMessageTo(Axis, "Lucie-Anton: good hunting over the channel. Weather reports clear skys with mild cloudbase at 1500 meters.");
        SendScreenMessageTo(Allies, "Sector control reports 79 squadron on inbound leg to patrol SE Dover area. Over.");
    }

    private void SendScreenMessageTo(int army, string message)
    {
        if (army == All)
        {
            GamePlay.gpHUDLogCenter(message);
        }
        else
        {
            //Singleplayer (for Testing)
            if (GamePlay.gpRemotePlayers() == null ||
                GamePlay.gpRemotePlayers().Length <= 0)
            {
                if (GamePlay.gpPlayer() != null &&
                    GamePlay.gpPlayer().Army() == army)
                {
                    GamePlay.gpHUDLogCenter(message);
                }
            }
            else // Multiplayer
            {
                var playersInArmy = new List<Player>();

                foreach (var player in GamePlay.gpRemotePlayers())
                {
                    if (player.Army() == army)
                    {
                        playersInArmy.Add(player);
                    }
                }
                
                GamePlay.gpHUDLogCenter(playersInArmy.ToArray(), message);
            }
        }
    }

    private void SendChatMessageTo(int army, string message)
    {
        if (army == All)
        {
            GamePlay.gpLogServer(null, message, null);
        }
        else
        {
            //Singleplayer (for Testing)
            if (GamePlay.gpRemotePlayers() == null ||
                GamePlay.gpRemotePlayers().Length <= 0)
            {
                if (GamePlay.gpPlayer() != null &&
                    GamePlay.gpPlayer().Army() == army)
                {
                    GamePlay.gpLogServer(null, message, null);
                }

            }
            else // Multiplayer
            {
                var playersInArmy = new List<Player>();

                foreach (var player in GamePlay.gpRemotePlayers())
                {
                    if (player.Army() == army)
                    {
                        playersInArmy.Add(player);
                    }
                }

                GamePlay.gpLogServer(playersInArmy.ToArray(), message, null);
            }
        }
    }
}
Thank you so much for your help everyone.

Cheers

Gromic
__________________
I5-750 @ 3,8GHz / MSI P55-GD65 / MSI GTX570 Twin Frozr II / 4x2GB G.Skill 1600MHz / Corsair TX650 PSU / RAID 0 2x640GB WD Black
W7 Pro x64 SP1 / MS FFB2 +Saitek X45 / Freetrack + NP Clip Pro + PS3 Eye / Samsung BX2450 24" HDMI LED
Reply With Quote
  #16  
Old 10-04-2011, 10:34 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

@ FG28_Kodiak
I am making a simple mission on Steppe map and trying to modify a script by TheEnlightenedFlorist which sends messages to a particular player in MP onPlaceEnter.

I want to define a new method to do this in 3 languages, but I do not know how to do it correctly. Also I included a multi-engine aircraft into limited list and wonder if the script would kill its engines correctly.

I included my questions into remarks. Would be grateful for any advice. Thank you for all your great help!

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

using System.Diagnostics;

/**
 * Parts of the script were taken from:
 * 
 * Operation Dynamo v2.0 
 * A multiplayer mission for IL-2 Sturmovik: Cliffs of Dover
 * @author TheEnlightenedFlorist
 * http://forum.1cpublishing.eu/showthread.php?t=23579&highlight=operation+dynamo
 * */

public class Mission : AMission
{
   
    //allowed and currently flying aircraft
    int allowed109s = 12;
    int current109s = 0;

    int allowedSpit2s = 7;
    int currentSpit2s = 0;

    int allowed110s = 4;
    int current110s = 0;


    public override void OnBattleStarted()
    {
        base.OnBattleStarted();

        //listen to events from all missions.
        MissionNumberListener = -1;

    }

    // Makes any FMB trigger/action pair work if they have the same name.
    //public override void OnTrigger(int missionNumber, string shortName, bool active)
    //{
    //    base.OnTrigger(missionNumber, shortName, active);
    //    AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
    //    if (action != null)
    //        action.Do();
    //}


    public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);

        // test
        // notAvailableMsg();

        if (actor != null && actor is AiAircraft)
        {
            //check limited aircraft
            switch ((actor as AiAircraft).InternalTypeName())
            {
                case "bob:Aircraft.Bf-109E-4":
                    {
                        current109s++;
                        if (current109s > allowed109s)
                        {
                            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                            notAvailableMsg(new Player[] { player });
                            //GamePlay.gpHUDLogCenter(new Player[] { player }, "Aircraft not available! Choose another aircraft.");
                        }
                        break;
                    }
                case "bob:Aircraft.SpitfireMkIIa":
                    {
                        currentSpit2s++;
                        if (currentSpit2s > allowedSpit2s)
                        {
                            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                            notAvailableMsg(new Player[] { player });
                            //GamePlay.gpHUDLogCenter(new Player[] { player }, "Aircraft not available! Choose another aircraft.");
                        }
                        break;
                    }
                case "bob:Aircraft.Bf-110C-7":
                    {
                        current110s++;
                        if (current110s > allowed110s)
                        {
                            //(actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure); // Is this line for single-engined only? только для одномоторных?

                            // Will this do for multi-engine?
                            int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum();
                            for (int i = 0; i < iNumOfEngines; i++)
                            {
                                aircraft.hitNamed((part.NamedDamageTypes)Enum.Parse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
                            }

                            notAvailableMsg(new Player[] { player });
                            //GamePlay.gpHUDLogCenter(new Player[] { player }, "Aircraft not available! Choose another aircraft.");
                        }
                        break;
                    }
            }
        }
    }

    // Trying to make a new method... Does it look correct?
    public void notAvailableMsg(Player player)
    {
        switch (player.LanguageName())
        {
            case "de":
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Too many aircrafts of this type! Choose another aircraft.");
                break; //need translation please
            case "ru":
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Слишком много самолетов данного типа! Выберите другой самолет.");
                break;
            default:
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Too many aircrafts of this type! Choose another aircraft.");
                break;
        }
    }

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);

        if (actor != null && actor is AiAircraft)
        {
            //check limited aircraft
            switch ((actor as AiAircraft).InternalTypeName())
            {
                case "bob:Aircraft.Bf-109E-4":
                    current109s--;
                    break;
                case "bob:Aircraft.SpitfireMkIIa":
                    currentSpit2s--;
                    break;
                case "bob:Aircraft.Bf-110C-7":
                    current110s--;
                    break;
            }
        }
    }

Last edited by Ataros; 10-04-2011 at 10:39 PM.
Reply With Quote
  #17  
Old 10-05-2011, 04:32 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Script corrected:
Code:
using System;
using System.Collections;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

using System.Diagnostics;

/**
 * Parts of the script were taken from:
 * 
 * Operation Dynamo v2.0 
 * A multiplayer mission for IL-2 Sturmovik: Cliffs of Dover
 * @author TheEnlightenedFlorist
 * http://forum.1cpublishing.eu/showthread.php?t=23579&highlight=operation+dynamo
 * */

public class Mission : AMission
{

    //allowed and currently flying aircraft
    int allowed109s = 12;
    int current109s = 0;

    int allowedSpit2s = 7;
    int currentSpit2s = 0;

    int allowed110s = 4;
    int current110s = 0;


    public override void OnBattleStarted()
    {
        base.OnBattleStarted();

        //listen to events from all missions.
        MissionNumberListener = -1;

    }

    // Makes any FMB trigger/action pair work if they have the same name.
    //public override void OnTrigger(int missionNumber, string shortName, bool active)
    //{
    //    base.OnTrigger(missionNumber, shortName, active);
    //    AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
    //    if (action != null)
    //        action.Do();
    //}


    public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);

        // test
        // notAvailableMsg();

        if (actor != null && actor is AiAircraft)
        {
            //check limited aircraft
            switch ((actor as AiAircraft).InternalTypeName())
            {
                case "bob:Aircraft.Bf-109E-4":
                    {
                        current109s++;
                        if (current109s > allowed109s)
                        {
                            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                            notAvailableMsg(player);
                            //GamePlay.gpHUDLogCenter(new Player[] { player }, "Aircraft not available! Choose another aircraft.");
                        }
                        break;
                    }
                case "bob:Aircraft.SpitfireMkIIa":
                    {
                        currentSpit2s++;
                        if (currentSpit2s > allowedSpit2s)
                        {
                            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                            notAvailableMsg(player);
                            //GamePlay.gpHUDLogCenter(new Player[] { player }, "Aircraft not available! Choose another aircraft.");
                        }
                        break;
                    }
                case "bob:Aircraft.Bf-110C-7":
                    {
                        current110s++;
                        if (current110s > allowed110s)
                        {
                            //(actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure); // Is this line for single-engined only? только для одномоторных?

                            // Will this do for multi-engine?
                            int iNumOfEngines = ((actor as AiAircraft).Group() as AiAirGroup).aircraftEnginesNum();
                            for (int i = 0; i < iNumOfEngines; i++)
                            {
                                (actor as AiAircraft).hitNamed((part.NamedDamageTypes)Enum.Parse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
                            }

                            notAvailableMsg(player);
                            //GamePlay.gpHUDLogCenter(new Player[] { player }, "Aircraft not available! Choose another aircraft.");
                        }
                        break;
                    }
            }
        }
    }

    
    public void notAvailableMsg(Player player)
    {
        switch (player.LanguageName())
        {
            case "de":
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Limit für diesen Flugzeugtyp erreicht! Wähle ein anderes Muster!");
                break; 
            case "ru":
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Слишком много самолетов данного типа! Выберите другой самолет.");
                break;
            default:
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Too many aircrafts of this type! Choose another aircraft.");
                break;
        }
    }

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);

        if (actor != null && actor is AiAircraft)
        {
            //check limited aircraft
            switch ((actor as AiAircraft).InternalTypeName())
            {
                case "bob:Aircraft.Bf-109E-4":
                    current109s--;
                    break;
                case "bob:Aircraft.SpitfireMkIIa":
                    currentSpit2s--;
                    break;
                case "bob:Aircraft.Bf-110C-7":
                    current110s--;
                    break;
            }
        }
    }
changed:
notAvailableMsg(new Player[] { player }); -to-> notAvailableMsg(player);
notAvailableMsg needs a argument from type Player not an array of it.

aircraft.hitNamed(...); -to-> (actor as AiAircraft).hitNamed(...)
aircraft was not declared - as alternative you can declare AiAircraft aircraft = actor as AiAircraft;

----
//(actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0Tot alFailure); // Is this line for single-engined only?
Yes, you kill the first engine with it.

// Will this do for multi-engine?
int iNumOfEngines = ((actor as AiAircraft).Group() as AiAirGroup).aircraftEnginesNum();
for (int i = 0; i < iNumOfEngines; i++)
{
(actor as AiAircraft).hitNamed((part.NamedDamageTypes)Enum.P arse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
}
Yes its correct.

"Too many aircrafts of this type! Choose another aircraft."
translated into german:
"Limit für diesen Flugzeugtyp erreicht! Wähle ein anderes Muster!"

Last edited by FG28_Kodiak; 10-05-2011 at 05:04 AM.
Reply With Quote
  #18  
Old 10-05-2011, 07:53 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Thank you very much!
Reply With Quote
  #19  
Old 10-07-2011, 01:56 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Made some rework on the script:

latest version:
http://forum.1cpublishing.eu/showpos...8&postcount=41

Added a exept version:
private void sendChatMessageTo(int army, string[] exepttoplayerlanguages, string msg, object[] parms)
private void sendScreenMessageTo(int army, string[] exepttoplayerlanguages, string msg, object[] parms)
Second Argument is a array of string.
so you can enter the languages this message should not be send
sendScreenMessageTo(-1, new string[] { "de", "ru" }, "Hello", null);

usefull if you have send a Message to for example the german players but dont want send a other language message to them
sendScreenMessageTo(-1, "de" }, "Hallo", null);
sendScreenMessageTo(-1, new string[] { "de" }, "Hello", null);
so the germans (with the german game version) get the german "Hallo"
and all other players gets the english "Hello".

Last edited by FG28_Kodiak; 10-12-2011 at 11:29 AM.
Reply With Quote
  #20  
Old 10-07-2011, 03:17 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Just WOW! A lot of work and quality one. I will use it in a new mission version.

BTW can I replace my methods that send messages to individual players with your methods somehow? I use methods like follows:
Code:
    private void objMsg(Player player)
    {
        switch (player.LanguageName())
        {
            case "de":
                GamePlay.gpLogServer(new Player[] { player }, "Achieve air superiority and attack ground targets in C5, D4 and E3!", null);
                break;
            case "ru":
                GamePlay.gpLogServer(new Player[] { player }, "Обеспечьте превосходство в воздухе и атакуйте наземные цели в квадратах C5, D4 и E3!", null);
                break;
            default:
                GamePlay.gpLogServer(new Player[] { player }, "Achieve air superiority and attack ground targets in C5, D4 and E3!", null);
                break;
        }
    }
E.g. can new Player[] { player } be used instead of army in your methods? It is not that important, just want to know.

I will replace "de" message if you give me a translation
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 05:01 PM.


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