Official Fulqrum Publishing forum

Official Fulqrum Publishing forum (http://forum.fulqrumpublishing.com/index.php)
-   FMB, Mission & Campaign builder Discussions (http://forum.fulqrumpublishing.com/forumdisplay.php?f=203)
-   -   Hud output depending on side choosen (http://forum.fulqrumpublishing.com/showthread.php?t=26623)

Gromic 10-01-2011 11:32 AM

Hud output depending on side choosen
 
Hi chaps,

just a quick and dirty question. Is it possible to generate output text using GamePlay.gpHUDLogCenter depending on the side you are flying on (multiplayer mission).

Example: If you fly red and a submission starts, red pilots would see a message ie. "64 Squadron patroling west of Rye" whereas a blue pilot would read "Enemy formation spotted west of Rye". Something along that line.

Cheers

Gromic

FG28_Kodiak 10-01-2011 12:17 PM

yes its possible, i've made two methods for this case:

See Code at
http://forum.1cpublishing.eu/showpos...8&postcount=41


usage:

sendScreenMessageTo(1, "test to red", null);
sendScreenMessageTo(2, "test to blue", null);
sendChatMessageTo(1,"test to red", null);
sendChatMessageTo(2,"test to blue", null);

to give additional Information for null you can use "new object[]{ object})
example:
int redpoints = 20;

sendScreenMessageTo(1, "Red has {0} Points", new object[]{ redpoints });

Ataros 10-01-2011 01:46 PM

Thank you very much for examples, Kodiak. I have a few questions before I can actually use it.

What is ArmyAll? Why don't you use it in the 1st example? Does this parameter exist in the game engine or I just type it in instead of 1 or 2? Why don't I just type "null" or say "-1" instead?

Can army be = 0 i.e. a message to those who did not select an army yet.

How can Localized messages http://forum.1cpublishing.eu/showthread.php?t=26444 be integrated into these scripts? I do not what international players to read Cyrillic text as well so can it be e.g.
Code:

if (ru version) Russian text
else English text?

Thank you for all the help you provide on scripts.

FG28_Kodiak 10-01-2011 02:17 PM

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);

Ataros 10-01-2011 05:55 PM

Quote:

Originally Posted by FG28_Kodiak (Post 342768)
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!" ?

FG28_Kodiak 10-01-2011 06:22 PM

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 ;)

FG28_Kodiak 10-02-2011 04:21 AM

So integrate player language:

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

Ataros 10-02-2011 09:14 AM

Quote:

Originally Posted by FG28_Kodiak (Post 342820)
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?

FG28_Kodiak 10-02-2011 09:51 AM

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.

Gromic 10-02-2011 11:28 AM

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


All times are GMT. The time now is 12:44 AM.

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