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-01-2011, 03:17 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Oh sorry ArmyAll is -1, just copy the methods from a script i made and forgotten to change this.

normally i use
const int ArmyAll = -1;
const int ArmyRed = 1;
const int ArmyBlue = 2;
at the beginning of my scripts.


have corrected the script so if you want send a Message to All you can use
sendChatMessageTo(-1, "Test To All", null);
sendScreenMessageTo(-1, "Test To All", null);


for your localized messages you can use
sendChatMessageTo(-1, GetLocalizedMessage("ru", "Hello"), null);

Last edited by FG28_Kodiak; 10-01-2011 at 03:59 PM.
Reply With Quote
  #2  
Old 10-01-2011, 06:55 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Quote:
Originally Posted by FG28_Kodiak View Post
for your localized messages you can use
sendChatMessageTo(-1, GetLocalizedMessage("ru", "hello"), null);
Does "ru" here mean that the message will be sent only to owners of a RU version?

But what to do if I want to send same message to everyone but in 2 languages? Will this do?
Code:
sendChatMessageTo(-1, GetLocalizedMessage( , "hello"), null);

private string GetLocalizedMessage(string lang, string key)
{
   switch(key)
   {
      case "hello":
      {
         if lang = "ru"
         {
            return "Привет!";
         }
	     else 	
         {
            return "Hello!";
         }
      } break;
   }
   return String.Empty;
}
Isn't "hello" a key that corresponds to both "Привет!" and "Hello!" ?
Reply With Quote
  #3  
Old 10-01-2011, 07:22 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

No your GetLocalizedMessage does nothing else then "translate" the hello in the language you specify.

There is a way to send a message to a player in his language.
The Player object contends a method called LanguageName()

so for remoteplayer you can use:
Code:
foreach (Player pl in GamePlay.gpRemotePlayers())
        {
           if  (pl.LanguageName().Equals("de"))
           {
               GamePlay.gpHUDLogCenter(new Player[]{pl}, "Hallo", null);
           }
           else if (pl.LanguageName().Equals("ru"))
           {
               GamePlay.gpHUDLogCenter(new Player[] { pl }, "Привет!", null);
           }
           else GamePlay.gpHUDLogCenter(new Player[] { pl }, "Hello", null);
        }
Will integrate this in my script tomoro, now its time to relax


@all
can you please test your language Version with:

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

public class Mission : AMission
{
    public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);
        
        GamePlay.gpLogServer(null, "\n\nYour language: {0}\n\n", new object[] { player.LanguageName() });
    }
}
german is "de" (tested myself)
english is "en" (not tested)
russian is "ru" (not tested)
so can anyone with this language version check this for me?

But i think the best is to add a option to
private void sendChatMessageTo(int army, string playerlanguage, string msg, object[] parms)
so it will be possible to use
sendChatMessageTo(1, "en", "Hello", null);
so it will send it only to the red players with english language version.

Tomorow

Last edited by FG28_Kodiak; 10-01-2011 at 07:44 PM.
Reply With Quote
  #4  
Old 10-02-2011, 05:21 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

So integrate player language:

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

Last edited by FG28_Kodiak; 10-12-2011 at 12:28 PM. Reason: corrected script for send messages to all with different languages
Reply With Quote
  #5  
Old 10-02-2011, 10:14 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Quote:
Originally Posted by FG28_Kodiak View Post
There is a way to send a message to a player in his language.
The Player object contends a method called LanguageName()
Thank you so much! This is the piece I was missing.

Tested Russian is "ru"

ps. The only thing which is not included now is separate messages to bombers and to fighters. IIRC there are 2 types of bombers: Bomber and DiveBomber. Are there several types of fighters too? Is HeavyFighter belong to Fighter type or it is a separate type?

Last edited by Ataros; 10-02-2011 at 10:20 AM.
Reply With Quote
  #6  
Old 10-02-2011, 10:51 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Possible are:

AircraftType.DiveBomber
AircraftType.Bomber
AircraftType.AmphibiousPlane
AircraftType.TorpedoBomber
AircraftType.Transport
AircraftType.BNZFighter
AircraftType.Fighter
AircraftType.Glider
AircraftType.HeavyFighter
AircraftType.JaBo
AircraftType.SailPlane
AircraftType.Scout
AircraftType.Sturmovik
AircraftType.TNBFighter
AircraftType.UNKNOWN

So the only way is to test all playable planes with
GamePlay.gpLogServer(null, "AircraftType: {0}", new object[] {(actor as AiAircraft).Type()});

Example

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

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

GamePlay.gpLogServer(null, "AircraftType: {0}", new object[] {(actor as AiAircraft).Type()});
}
}

and so test which type a plane can be and then divide it into groups.

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

oh wow! Thanks guys.

I'll give it a try and let you know how it worked out. Be advised that it may take some time 'cause I'm new to this stuff. It's like learning to ride a bike - might break a few bones in the process.

Thanks a million again!

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
  #8  
Old 10-03-2011, 10: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
  #9  
Old 10-04-2011, 11: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 11:39 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

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 04:41 PM.


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