How to add Audio message if neutral or enemy hits local?

Hello, i want to build a simple script thats give me a audio warning if a neutral or enemy hits local. But my Programming skills are to low to do it. Hope some one can help me.

I have found some scripts here in forum, but that doenst work for me.

boolIsNeutralOrEnemy(IChatParticipantEntry participantEntry) =>
   !(participantEntry?.FlagIcon?.Any(flagIcon =>
     new[] { “Pilot is in your (fleet|corporation)” }
     .Any(goodStandingText =>
        flagIcon?.HintText?.RegexMatchSuccessIgnoreCase(goodStandingText) ?? false)) ?? false);
while(true)
{

var    chatLocal =
     Sanderling.MemoryMeasurementParsed?.Value?.WindowChatChannel
     ?.FirstOrDefault(windowChat => windowChat?.Caption?.RegexMatchSuccessIgnoreCase(“local”) ?? false);

Host.Log(chatLocal?.ParticipantView?.Entry?.Count());
     if(chatLocal?.ParticipantView?.Entry?.Any(IsNeutralOrEnemy) ?? true)    // will be true if (null == chatLocal) 
 {

System.Media.SoundPlayer simpleSound = new System.Media.SoundPlayer(@“C:Usersairiesaudioalarma.wav”);
              simpleSound.Play();
     
 }

//    wait for four seconds before repeating.
    Host.Delay(4000);
    //    make sure new measurement will be taken.
    Sanderling.InvalidateMeasurement();

}

Hello Fairies,

the following script works for me to play a sound:

new System.Media.SoundPlayer(@"c:\Windows\Media\chimes.wav").Play();

You will have to make sure you have a suitable sound file at the given location.

When we have the sound working, we can continue with the rest.

Thx, this work fine for me.

Here is the full script, dont know how its work, but its work and i am happy with it

	Sanderling.Parse.IMemoryMeasurement Measurement => Sanderling?.MemoryMeasurementParsed?.Value;
var    chatLocal =
     Sanderling.MemoryMeasurementParsed?.Value?.WindowChatChannel
     ?.FirstOrDefault(windowChat => windowChat?.Caption?.RegexMatchSuccessIgnoreCase("local") ?? false);
bool hostileOrNeutralsInLocal => 1 != chatLocal?.ParticipantView?.Entry?.Count(IsNeutralOrEnemy); 
bool IsNeutralOrEnemy(IChatParticipantEntry participantEntry) =>
   !(participantEntry?.FlagIcon?.Any(flagIcon =>
     new[] { "Pilot is in your (fleet|corporation)" }
     .Any(goodStandingText =>
        flagIcon?.HintText?.RegexMatchSuccessIgnoreCase(goodStandingText) ?? false)) ?? false);
while(true)
{
var    chatLocal =
     Sanderling.MemoryMeasurementParsed?.Value?.WindowChatChannel
     ?.FirstOrDefault(windowChat => windowChat?.Caption?.RegexMatchSuccessIgnoreCase("local") ?? false);


 if(chatLocal?.ParticipantView?.Entry?.Count(IsNeutralOrEnemy) > 1)     
 {
Host.Log(hostileOrNeutralsInLocal);
Host.Log(chatLocal?.ParticipantView?.Entry?.Count(IsNeutralOrEnemy));
System.Media.SoundPlayer simpleSound = new System.Media.SoundPlayer(@"C:\Users\airies\Downloads\alarma.wav");
 	simpleSound.Play();
 }
Host.Delay(4000);

Sanderling.InvalidateMeasurement();
}

2 Likes

Thank you, that might be helpful for others.

Hello trying to use this script getting this error:

Failed:

System.Media.SoundPlayer simpleSound = new System.Media.SoundPlayer(@“‪F:\Downloads\script\tada.wav”);

That file is 100% at that location. Anyone got this working?

Sound is working for me, but you have to be sure you are using .wav file !
For some reason though… It alarms for blue also.
Not just if there is a neut / enemy

In the code you posted I can see the quote characters around the string literal are incompatible with C#. This is why you get a compilation error. To fix it use this code instead:

System.Media.SoundPlayer simpleSound = new System.Media.SoundPlayer(@"F:\Downloads\script\tada.wav");

The code only makes it not bleep for fleet/corp members.

This code is ALMOST great. Sadly it keeps beeping for the same person once their in local. Ideally it should be once or twice only per new local entrant.

Thanks, that worked.

I guess some people might not want the message to appear when the tooltip for the chat participant is Pilot is in your alliance.

If this applies to you, have a look at the following change:

1 Like

Could you possible also add “good/excellent” standing in it ?

Hi guys
Not been here for long.
@Viir Is it still possible to use this script : ) ?

Welcome back Ivar! :wave:

Maybe it is still possible, but I would not use it because I found a better way in the meantime. I made an example to demonstrate how to add an audio message, in a way that is better integrated with the current EVE Online bot framework:

To hear it in action, run it with this command:

botengine run-bot "https://github.com/Viir/bots/blob/e1c4dac983b8fdb597942ba02025b1d450ee8932/implement/applications/eve-online/eve-online-intel-tool"

This bot watches the local chat and plays a sound if there are neutral or enemy pilots.

For general information about the botengine command, see the guide at https://github.com/Viir/bots/blob/master/guide/how-to-run-a-bot.md

Hello Viir :wave:

I tried to run the bot, followed your instructions, but I’m not able to get it to work. I installed the BotEngine and opened cmd, copied this inside the window

C:\Users\BT\Desktop\Bot\BotEngine.exe run “https://github.com/Viir/bots/blob/e1c4dac983b8fdb597942ba02025b1d450ee8932/implement/applications/eve-online/eve-online-intel-tool/src/Bot.elm

and it tells me that there is a problem with the app source, “Seems like that app is not compatible with this version of the engine.”

Do you have any solution?

Best regards

K4mpfSock3

Welcome @K4mpfSock3!

Yes, the app code from that link is not compatible with the newest version of the engine for Windows.

I updated the local watch app code to work with the newest version of the engine. You can run it like this:

botengine  run  "https://github.com/Viir/bots/blob/8df52d373315bd5aa41a9d4a0ceef6ea6aa16bff/implement/applications/eve-online/eve-online-local-watch/src/Bot.elm"

The catalog entry is here: https://catalog.botengine.org/F337C2D7A83547ACC36122FC5F4B805A042AC8F3336F83F4DA2ED567F2CC26EC

Ok, this worked. Thank you!
But is there a way that the bot is running longer than 15 minutes?

Sure, to make the bot run longer than 15 minutes, add the --online-session option like so:

botengine  run  --online-session  "https://github.com/Viir/bots/blob/8df52d373315bd5aa41a9d4a0ceef6ea6aa16bff/implement/applications/eve-online/eve-online-local-watch/src/Bot.elm"

More about online sessions: https://to.botengine.org/guide/online-session