Openkore.com

OpenKore Forums
It is currently 23 Apr 2014, 10:11

All times are UTC - 5 hours [ DST ]





Post new topic Reply to topic  [ 58 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Sound alerts plugin [win32] - v1.3 [1.9] by Joseph
PostPosted: 20 Jun 2008, 05:48 
Offline
Noob
Noob

Joined: 26 May 2008, 11:01
Posts: 8
Been leeching from the forums for a long time already. Its time I did something in return. :lol:
Well this plugin wasn't made by me. Its made by Joseph and the link to the old forums is this

http://bibian.ath.cx/openkore/viewtopic ... 3356d3cafc

Been using this plugin all the while so I can personally ensure that it is fully functional.

Sound alerts plugin

Version for openkore SVN and old versions.

This plugin plays a sound when certain events happen.

How to change the color of the alert text?
Open control/consolecolors.txt and add alertSound <color> under the message section.

How to I hide the alert messages?
Add alertSound to the squelchDomains list in config.txt.

feel free to contribute if you can optimize/add features

Example config.txt entry:

Supported events:
public chat, public GM chat, private chat, private GM chat, emoticon, system message, map change, GM near, death, monster (monster name)

You should be able to figure out how to configure it from this example:

Code:

Code:
alertSound 1

alertSound {
  eventList public gm chat, public chat
  notInTown 1
  inLockOnly 1
  play SystemDefault
}

alertSound {
  eventList emoticon, death, monster Phreeoni, monster Baphomet
  notInTown 1
  inLockOnly 0
  play C:\windows\media\Windows XP Hardware Insert.wav
}





For openkore 1.9.3 SVN or above Version:
Thanks to h4rry84
Perl:
Code:
# alertsound plugin by joseph
# Fixed to 1.9.x version by h4rry84
# http://openkore.sourceforge.net/forum/viewtopic.php?t=2032
#
#
# This software is open source, licensed under the GNU General Public
# License, version 2.

package alertsound;

use strict;
use Plugins;
use Globals;
use Utils;
use Log qw(message);
use Network::Send;
use Utils::Win32;

Plugins::register('alertsound', 'plays sounds on certain events', \&Unload);
my $packetHook = Plugins::addHook('parseMsg/pre', \&CheckPacket);

sub Unload {
        Plugins::delHook('parseMsg/pre', $packetHook);
}

sub CheckPacket {
        return if (!$config{'alertSound'});

        my $hookName = shift;
        my $args = shift;
        my $switch = $args->{switch};
        my $msg = $args->{msg};


        if ($switch eq "008D") {
        # Public chat message.
                my $ID = substr($msg, 4, 4);
                my $msg_size = length($msg);
                my $chat = substr($msg, 8, $msg_size - 8);
                $chat =~ s/\000//g;
                my ($chatMsgUser, $chatMsg) = $chat =~ /([\s\S]*?) : ([\s\S]*)/;
                $chatMsgUser =~ s/ $//;

                if ($chatMsgUser =~ /^([a-z]?ro)?-?(Sub)?-?\[?GM\]?/i) {
                        alertSound("public GM chat");
                } else {
                        alertSound("public chat");
                }
        } elsif ($switch eq "0097") {
        # Private chat message.
                my $msg_size = length($msg);
                my $newmsg;
                Network::Receive->decrypt(\$newmsg, substr($msg, 28, length($msg)-28));
                $msg = substr($msg, 0, 28).$newmsg;
                my ($privMsgUser) = substr($msg, 4, 24) =~ /([\s\S]*?)\000/;
                my $privMsg = substr($msg, 28, $msg_size - 29);

                if ($privMsgUser =~ /^([a-z]?ro)?-?(Sub)?-?\[?GM\]?/i) {
                        alertSound("private GM chat");
                } else {
                        alertSound("private chat");
                }
        } elsif ($switch eq "009A") {
        # System message/GM message (is this always global?)
                alertSound("system message");
        } elsif ($switch eq "00C0") {
        # Emoticon
                my $ID = substr($msg, 2, 4);

                if ($players{$ID} && $ID ne $accountID) {
                        alertSound("emoticon");
                }
        } elsif ($switch eq "0091") {
        # Map change
                alertSound("map change");
        } elsif ($switch eq "0092") {
        # Map change - switching map servers
                alertSound("map change");
        } elsif ($switch eq "0095") {
        # Identify GM Names
                my $ID = substr($msg, 2, 4);

                if ($players{$ID} && %{$players{$ID}}) {
                        my ($name) = substr($msg, 6, 24) =~ /([\s\S]*?)\000/;
                        if ($name =~ /^([a-z]?ro)?-?(Sub)?-?\[?GM\]?/i) {
                                alertSound("GM near");
                        }
                }
        } elsif ($switch eq "0195") {
        #Identify GM Names
                my $ID = substr($msg, 2, 4);

                if ($players{$ID}) {
                        my ($name) = substr($msg, 6, 24) =~ /([\s\S]*?)\000/;
                        if ($name =~ /^([a-z]?ro)?-?(Sub)?-?\[?GM\]?/i) {
                                alertSound("GM near");
                        }
                }
        } elsif ($switch eq "0080") {
        # someone disappeared here
                my $ID = substr($msg, 2, 4);

                if ($ID eq $accountID) {
                # You are dead.
                        alertSound("death");
                }
        } elsif ($switch eq "0078") {
        # Existance packet used to tell if monster exists
                my $ID = substr($msg, 2, 4);
                my $type = unpack("S*",substr($msg, 14,  2));
                my $pet = unpack("C*",substr($msg, 16,  1));
                if (!$jobs_lut{$type} && $type >= 1000 && !$pet) {
                        my $display = ($::monsters_lut{$type} ne "")
                                ? $::monsters_lut{$type}
                                : "Unknown ".$type;
                        alertSound("monster $display");
                }
        } elsif ($switch eq "01D8") {
        # Existance packet used to tell if monster exists
                my $ID = substr($msg, 2, 4);
                my $type = unpack("S*",substr($msg, 14,  2));
                my $pet = unpack("C*",substr($msg, 16,  1));
                if (!$jobs_lut{$type} && $type >= 1000 && !$pet) {
                        my $display = ($::monsters_lut{$type} ne "")
                                ? $::monsters_lut{$type}
                                : "Unknown ".$type;
                        alertSound("monster $display");
                }
        }
}


##
# alertSound($event)
# $event: unique event name
#
# Plays a sound if alertSound is enabled,
# and if a sound is specified for the event.
#
# The config option "alertSound_#_eventList" should have a comma
# seperated list of all the desired events.
#
# Supported events:
# public chat, public GM chat, private chat, private GM chat, emoticon, system message
# map change, GM near, monster <monster name>
sub alertSound {
        return if (!$config{'alertSound'});
        my $event = shift;
        my $i = 0;
        for (my $i = 0; exists $config{"alertSound_".$i."_eventList"}; $i++) {
                next if (!$config{"alertSound_".$i."_eventList"});
                if (Utils::existsInList($config{"alertSound_".$i."_eventList"}, $event)
                && (!$config{"alertSound_".$i."_notInTown"} || !$cities_lut{$field->name().'.rsw'})
                && (!$config{"alertSound_".$i."_inLockOnly"} || $field->name() eq $config{'lockMap'})) {
                        message "Sound alert: $event\n", "alertSound";
                        Utils::Win32::playSound($config{"alertSound_".$i."_play"});
                        return;
                }
        }
}

return 1;




For old openkore version:

Perl:
Code:
# alertsound plugin by joseph
# http://openkore.sourceforge.net/forum/viewtopic.php?t=2032
#
#
# This software is open source, licensed under the GNU General Public
# License, version 2.

package alertsound;

use strict;
use Plugins;
use Globals;
use Utils;
use Log qw(message);
use Network::Send;
use WinUtils;

Plugins::register('alertsound', 'plays sounds on certain events', \&Unload);
my $packetHook = Plugins::addHook('parseMsg/pre', \&CheckPacket);

sub Unload {
        Plugins::delHook('parseMsg/pre', $packetHook);
}

sub CheckPacket {
        return if (!$config{'alertSound'});

        my $hookName = shift;
        my $args = shift;
        my $switch = $args->{switch};
        my $msg = $args->{msg};


        if ($switch eq "008D") {
        # Public chat message.
                my $ID = substr($msg, 4, 4);
                my $msg_size = length($msg);
                my $chat = substr($msg, 8, $msg_size - 8);
                $chat =~ s/\000//g;
                my ($chatMsgUser, $chatMsg) = $chat =~ /([\s\S]*?) : ([\s\S]*)/;
                $chatMsgUser =~ s/ $//;

                if ($chatMsgUser =~ /^([a-z]?ro)?-?(Sub)?-?\[?GM\]?/i) {
                        alertSound("public GM chat");
                } else {
                        alertSound("public chat");
                }
        } elsif ($switch eq "0097") {
        # Private chat message.
                my $msg_size = length($msg);
                my $newmsg;
                Network::Send::decrypt(\$newmsg, substr($msg, 28, length($msg)-28));
                $msg = substr($msg, 0, 28).$newmsg;
                my ($privMsgUser) = substr($msg, 4, 24) =~ /([\s\S]*?)\000/;
                my $privMsg = substr($msg, 28, $msg_size - 29);

                if ($privMsgUser =~ /^([a-z]?ro)?-?(Sub)?-?\[?GM\]?/i) {
                        alertSound("private GM chat");
                } else {
                        alertSound("private chat");
                }
        } elsif ($switch eq "009A") {
        # System message/GM message (is this always global?)
                alertSound("system message");
        } elsif ($switch eq "00C0") {
        # Emoticon
                my $ID = substr($msg, 2, 4);

                if ($players{$ID} && $ID ne $accountID) {
                        alertSound("emoticon");
                }
        } elsif ($switch eq "0091") {
        # Map change
                alertSound("map change");
        } elsif ($switch eq "0092") {
        # Map change - switching map servers
                alertSound("map change");
        } elsif ($switch eq "0095") {
        # Identify GM Names
                my $ID = substr($msg, 2, 4);

                if ($players{$ID} && %{$players{$ID}}) {
                        my ($name) = substr($msg, 6, 24) =~ /([\s\S]*?)\000/;
                        if ($name =~ /^([a-z]?ro)?-?(Sub)?-?\[?GM\]?/i) {
                                alertSound("GM near");
                        }
                }
        } elsif ($switch eq "0195") {
        #Identify GM Names
                my $ID = substr($msg, 2, 4);

                if ($players{$ID}) {
                        my ($name) = substr($msg, 6, 24) =~ /([\s\S]*?)\000/;
                        if ($name =~ /^([a-z]?ro)?-?(Sub)?-?\[?GM\]?/i) {
                                alertSound("GM near");
                        }
                }
        } elsif ($switch eq "0080") {
        # someone disappeared here
                my $ID = substr($msg, 2, 4);

                if ($ID eq $accountID) {
                # You are dead.
                        alertSound("death");
                }
        } elsif ($switch eq "0078") {
        # Existance packet used to tell if monster exists
                my $ID = substr($msg, 2, 4);
                my $type = unpack("S*",substr($msg, 14,  2));
                my $pet = unpack("C*",substr($msg, 16,  1));
                if (!$jobs_lut{$type} && $type >= 1000 && !$pet) {
                        my $display = ($::monsters_lut{$type} ne "")
                                ? $::monsters_lut{$type}
                                : "Unknown ".$type;
                        alertSound("monster $display");
                }
        } elsif ($switch eq "01D8") {
        # Existance packet used to tell if monster exists
                my $ID = substr($msg, 2, 4);
                my $type = unpack("S*",substr($msg, 14,  2));
                my $pet = unpack("C*",substr($msg, 16,  1));
                if (!$jobs_lut{$type} && $type >= 1000 && !$pet) {
                        my $display = ($::monsters_lut{$type} ne "")
                                ? $::monsters_lut{$type}
                                : "Unknown ".$type;
                        alertSound("monster $display");
                }
        }
}


##
# alertSound($event)
# $event: unique event name
#
# Plays a sound if alertSound is enabled,
# and if a sound is specified for the event.
#
# The config option "alertSound_#_eventList" should have a comma
# seperated list of all the desired events.
#
# Supported events:
# public chat, public GM chat, private chat, private GM chat, emoticon, system message
# map change, GM near, monster <monster name>
sub alertSound {
        return if (!$config{'alertSound'});
        my $event = shift;
        my $i = 0;
        for (my $i = 0; exists $config{"alertSound_".$i."_eventList"}; $i++) {
                next if (!$config{"alertSound_".$i."_eventList"});
                if (Utils::existsInList($config{"alertSound_".$i."_eventList"}, $event)
                && (!$config{"alertSound_".$i."_notInTown"} || !$cities_lut{$field{'name'}.'.rsw'})
                && (!$config{"alertSound_".$i."_inLockOnly"} || $field{name} eq $config{'lockMap'})) {
                        message "Sound alert: $event\n", "alertSound";
                        WinUtils::playSound($config{"alertSound_".$i."_play"});
                        return;
                }
        }
}

return 1;


Top
 Profile  
 
 Post subject: Re: Sound alerts plugin [win32] - v1.3 [1.9] by Joseph
PostPosted: 21 Jun 2008, 00:00 
Offline
Noob
Noob

Joined: 20 Jun 2008, 17:49
Posts: 1
So do I just paste it into the config.txt? I did that and it's not making any sounds...Sorry if I sound like a noob cause I started only a few days ago so...thanks in advance


Top
 Profile  
 
 Post subject: Re: Sound alerts plugin [win32] - v1.3 [1.9] by Joseph
PostPosted: 21 Jun 2008, 02:37 
Offline
Noob
Noob

Joined: 26 May 2008, 11:01
Posts: 8
You got to place this plugin into your openkore folder. Read on macros and plugins please.


Top
 Profile  
 
 Post subject: Re: Sound alerts plugin [win32] - v1.3 [1.9] by Joseph
PostPosted: 14 Jul 2008, 00:55 
Offline
Noob
Noob

Joined: 14 Jul 2008, 00:48
Posts: 1
This plugin realy works??? I've tried to use it ... but appear an error when i trie to put the bot on ...anyone have tested it for new openkore versions???


Top
 Profile  
 
 Post subject: Re: Sound alerts plugin [win32] - v1.3 [1.9] by Joseph
PostPosted: 22 Jul 2008, 05:08 
Offline
Noob
Noob

Joined: 22 Jul 2008, 05:03
Posts: 6
I'am sorry , but i've got some questions about this alertssound.pl data.
If i use this plugin and put the code into my config.txt and save alertsounds.pl in my plugins folder, what exactly will happen then?!
Will i just hear a special sound when somebody will pm me or write with me in puplic chat?!
Or will my bot talk with them as well?! Because it says you can chance "text color" .. but what text color have i to chance?!
And what message will this alert give out?! because there is the function to hide the "alert message"
Sorry for this nuubness , but i really tried to understand this all , but i couldn't actually ^^ :oops:


Top
 Profile  
 
 Post subject: Re: Sound alerts plugin [win32] - v1.3 [1.9] by Joseph
PostPosted: 24 Jul 2008, 15:21 
Offline
Noob
Noob
User avatar

Joined: 07 May 2008, 18:36
Posts: 11
I need to know if this can be used without the macro

And I have the 2.0.5.1 openkore version, but I don't see any "plugins" folder

Ah...and I don't have the SVN version...do I need it?

_________________
Image


Top
 Profile  
 
 Post subject: Re: Sound alerts plugin [win32] - v1.3 [1.9] by Joseph
PostPosted: 28 Aug 2008, 00:58 
Offline
Human
Human

Joined: 12 Jul 2008, 06:14
Posts: 33
Ok, I'm using this plugin, but the monster event is not working. I have all the configs, I can verify it does work (everytime @main activates it does beep), but having monster Kapha is not working, I tried with several monster names but it doesn't work. I didn't modify anything in the plugin code and I'm using the version for 1.9.3 and above SVN (I'm using SVN version). What could be wrong?


Top
 Profile  
 
 Post subject: Re: Sound alerts plugin [win32] - v1.3 [1.9] by Joseph
PostPosted: 29 Aug 2008, 17:04 
Offline
Human
Human

Joined: 12 Jul 2008, 06:14
Posts: 33
Umm bump? Anyone know why won't it beep on monsters?


Top
 Profile  
 
 Post subject: Re: Sound alerts plugin [win32] - v1.3 [1.9] by Joseph
PostPosted: 29 Aug 2008, 19:42 
Offline
Noob
Noob

Joined: 29 Aug 2008, 16:47
Posts: 3
do you even need macro plugin for this to work? i am able to load up this plugin and it shows up when i type in plugins to see the list.

when i have a friend whisper me or talk in general chat though, i dont get a sound. someone please help?


Top
 Profile  
 
 Post subject: Re: Sound alerts plugin [win32] - v1.3 [1.9] by Joseph
PostPosted: 29 Aug 2008, 21:43 
Offline
Perl Monk
Perl Monk

Joined: 04 Apr 2008, 17:26
Posts: 797
Makubex wrote:
I need to know if this can be used without the macro

And I have the 2.0.5.1 openkore version, but I don't see any "plugins" folder

Ah...and I don't have the SVN version...do I need it?

If only modern operating systems had the capability to create directories. Sigh, I guess we can dream, though. Yeah? :)

Anyway, this plugin is so out of date I can't believe it actually still loads error-free.

_________________
dual 4/3 triple twisted kanthal @ .24Ω, 73.5W


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 58 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[ Time : 0.061s | 14 Queries | GZIP : On ]