![]() |
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 |
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 }); |
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 |
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); |
Quote:
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); |
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()) @all can you please test your language Version with: Code:
using System; 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 ;) |
|
Quote:
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? |
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. |
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 |
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 :mad::grin: 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 |
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 |
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) 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! |
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 } |
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; Cheers Gromic |
@ 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; |
Script corrected:
Code:
using System; 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!" |
Thank you very much!
|
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". |
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) I will replace "de" message if you give me a translation :) |
Not at the moment but its no problem to integrate this. :rolleyes:
"Achieve air superiority and attack ground targets in C5, D4 and E3!" in german "Luftüberlegenheit erringen und Bodenziele in C5, D4 und E3 angreifen!" |
So integrated:
latest version: http://forum.1cpublishing.eu/showpos...8&postcount=41 first argument is from type Player, for this example i use the player from OnPlaceEnter(...), so the player sees Hallo if he is german and a english "Hello" he is not. sendScreenMessageTo(player, "de", "Hallo", null); sendChatMessageTo(player, "de", "Hallo", null); sendScreenMessageTo(player, new string[] {"de"}, "Hello", null); sendChatMessageTo(player, new string[] { "de" }, "Hello", null); |
Sounds like magic! :) Thank you!
|
2 Attachment(s)
Hi, Kodiak!
I am facing some issues integrating your message system into my Steppe mission. We plan to put the mission up on R2 or R3 (Repkas) after the official patch is out an I hope you can help me to get it working. I am obviously making something wrong but can not get through it for 3 days already due to lack of basic knowledge. I divided all the script into #region-s and commented the regions in which messages are available. I described the parts which are not working in comments. Please let me know if it is comfortable for you or you want me to paste the list of issues and parts of the script here on the forum. In general the issue is that script works on a hosted server which I start ingame (and no one connected). So it sends messages to me as a host. But the script does not work on a dedicated server when I connect to it. The "NET settings" message creates so many errors that a game freezes and some lines of code are skipped like current109s++ in not calculated. I attach also a server log with errors I get. Thanks in advance for any advice. |
Seems the problem is the
Timeout(12, () => may be the player is no longer valid after 12 sec, can you test it without the timeout or a shorter one? |
Quote:
I am still sitting and waiting in my aircraft after 12 seconds, so both a player and an aircraft exist. Why can he be invalid? PS. Sorry, maybe I did not explain it in detail. Timeout(12, () => is related to Code:
msgTooManyAircraft(player); Code:
Timeout(20, () => The part which does not work is Code:
//// NET settings msg - do not work on dedicated server, works on hosted server for host at least And the complete code of OnTickGame sends messages only offline or on a hosted server to the host. Does not send messages to remote player on a dedicated server. |
At the moment its only a possibility.
You get a "Object reference not set to an instance of an object" Error. Thats means the script would use a object wich is null, but at the moment i dont see why the player should be null at the moment OnPlaceEnter is active, so may be its null after 12 sec. At time i dont trust the memory management of a dedicated server ;) |
Edited the previous post a bit. The messages sent after 12 seconds are delivered.
|
GamePlay.gpRemotePlayers().Length <= 0 should be the bug (to silly btw) GamePlay.gpRemotePlayers().Length > 0 is the correct version.
Next time i should test my code on Multiplayer conditions before give it to the public. Shame on me. latest version: http://forum.1cpublishing.eu/showpos...8&postcount=41 |
Thank you very much! You know mistakes are a pathway to future success.
So, the "NET message" in OnPlaceEnter will also work I hope. Will try it tonight hopefully. |
I am using about 10-20 timeout statements in onTickGame to send messages. Does it slow down server processor if server has to count 10-20 timers at the same time or not?
Maybe it should be optimized to have only one timer? |
Made little additions to the code, to avoid exeptions.
latest version: http://forum.1cpublishing.eu/showpos...8&postcount=41 |
Thank you! Testing on R2 now.
|
I get this OnPlaceEnter if enable my "NET message"
Code:
[13:01:51] Server: 3GIAP_Atas enters the battle. Code:
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) |
Could you change the message for testing please, seems it's a problem with the string, may be to long or the 'ISDN' :confused:
|
Quote:
2nd issue still remains. I see all messages from OnTickGame ONLY in server log but not on screen because they are sent only to server, not to remote players. Code:
[13:17:48] Server to [Server]: Please leave your feedback at forum.1cpublishing.eu in CloD section. We highly appreciate it! |
Could it be that GamePlay.gpPlayer is the server on dedicated?
Could you please test it with: Code:
using System; |
The 1st problem with errors is solved! The chat message was too long.
Thank you! Quote:
Thanks, will test soon. EDIT. Ah, 10 people are playing can not restart now ((. |
Ok i found out how to run a dedicated Server on my own Computer, so i can test it by my self ;)
|
Quote:
BTW you can join your own dedicated server from the same PC with your client if you run the dedi via a shortcut (creating a windows shortcut for a dedi with -server in properties). |
Yes i get the english messages at my private testserver.
Btw the messages are to long for my screen resolution (19' 1280*1024), so i can't see the begin and the end of the message. I also get the OnTickGame Messages (with my latest version), good to know that GamePlay.gpPlayer() is the server so we can send testmessages to the LOG. ;) But i ever think gpPlayer is for Singleplayer and gpRemotePlayer is for Multiplayer, so sorry for the inconvenience :( SO latest Version: Code:
using System; |
Thank you very much! Will try to install it tonight.
|
All messages work finally (in Russian at least)! Runs on Repka 2 now. Thank you very much!
|
What these errors can be related? Just had server launcher crash some time after these errors.
Code:
[21:44:59] |
Nothing to do with my part,
something in OnPlaceLeave going wrong. You should test actor for null value: if (actor != null) //missing { if ((actor as AiAircraft).InternalTypeName() == "bob:Aircraft.DH82A") ... } |
Thank you very much! It's a hard science for me, ahh...
|
You can declare a function as:
private void sendScreenMessageTo(int army, string msg, params object[] parms) then array for the parameters will be generated automatically, the call will be easier to look: sendScreenMessageTo(myarmy, "I am at grid {0}, {1}", xpos, ypos); Also, lowercase first letter in class or function name is Java style, not C#. Microsoft C# Code Design Guidelines. |
I use lowercase first letters for private methods and uppercase for public, thats all. And i am not interested in "Style Guidlines" from Microsoft.
And i don't use the params parameter to avoid confusion between (GamePlay) void gpLogServer(Player[] to, string format, object[] args); and my methods. btw. Welcome to the forum! |
Thank you.
As we say: our business - to offer, your - to refuse. In the end, everyone chooses his own way. ;) |
I am trying to use the \n within the " " of a sting to create a new line for long screen messages and it seems that I am not getting it right.
for example: SendScreenMessageTo(1, "Note\nPress TAB and 4 at ANY time\nLoad any submission available in the list"); Any idea what I might be missing? |
It's not possible.
GamePlay.gpHUDLogCenter(..) doesn't support it, i've tried it too ;). You can use the timeout command to show one message after another. Code:
SendScreenMessageTo(1, "Note"); |
Thaaaaaaank you!!
I will do just that :) |
to Kodiak
Hi! I use your script to send messages: Code:
sendChatMessageTo(-1, "blablabla", new object[] { }); //TEST Code:
private void sendScreenMessageTo(int army, string msg, object[] parms) Code:
[21:56:12] ================================================= Code:
public void messageTaskComplite(int numberDeadUnit, int taskPrice, int armyTask, string msg) Code:
public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages) What method do I need to use on the dedi server? getLocalizedMessage("getPointsRED") turn off(always "en") |
Can you test these please, i ve made some rework meanwhile:
Code:
private void sendScreenMessageTo(int army, string msg, params object[] args) example int redpoints =10; int bluepoints =20; sendScreenMessageTo(-1, "Red have {0} Points / Blue: {1} Points", redpoints, bluepoints); or use it without sendScreenMessageTo(-1, "Welcome to our Server"); |
Quote:
|
All times are GMT. The time now is 09:15 AM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.