Jump to content

Auto Announcer with NextID and MangChat support


Guest xeross155

Recommended Posts

Hey Folks

I have recently reimplemented the Auto-Announcer I edited a while back, but the old code was kind of ugly and not properly written. So I took the code and reorganized and recoded a big part of it to create this new version.

Features

  • * You can set which announcement comes next on every announcement
    * If you don't specify a next announcement it'll take a random one
    * Announcement can be shown in the following places

    • * Chat Window
      * Top-Middle of the screen
      * In the mangchat channel

Getting this new version

Ok in order to get this new version you have to pull it from github the clone url is

git://github.com/xeross/mangos.git

and the branch name is "broadcaster".

Making it work with mangchat

In order to make this work with mangchat you need to use my version of it, or you have to edit your current mangchat source code for this to work. My mangchat version is at the same repository as my broadcaster under the branch "mangchat".

I hope you enjoy this release and if you have any questions or bugs you found let me know.

Regards, Xeross

News [03 December 2009]

I fixed the config options in the branch and updated it to latest mangos

News [02 April 2010]

Updated branch to revision 9652 and added patch for download

News [21 August 2010]

Updated branch to 10387

Link to comment
Share on other sites

  • Replies 106
  • Created
  • Last Reply

Top Posters In This Topic

well that is good news.. currently im using sqlyog but i would like to allow other GM level players to add/edit auto messages without giving them full access to the database :D

Also I have noticed that in your config file

AutoBroadcast.Enabled = 1
AutoBroadcast.Position = 2
AutoBroadcast.Interval = 30000

should be

Broadcast.Enabled = 1
Broadcast.Position = 2
Broadcast.Interval = 30000

or your settings will be ignored

Link to comment
Share on other sites

  • 1 month later...

Mb smbd wii need this fix in diff:

diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index b919b50..3e7c8cb 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -1405,6 +1405,6 @@ Ra.Secure = 1
#
###################################################################################################################

-AutoBroadcast.Enabled = 1
-AutoBroadcast.Position = 2
-AutoBroadcast.Interval = 30000
+Broadcast.Enabled = 1
+Broadcast.Position = 2
+Broadcast.Interval = 30000

Link to comment
Share on other sites

  • 5 weeks later...
git clone git://github.com/xeross/mangos.git xeross

cd xeross

git checkout origin/broadcaster

git checkout -b broadcaster

git diff origin/master broadcaster > broadcaster.patch

Something like that, However my master and Broadcaster branch don't have the same revision at the moment.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Hello everyone,

I've been trying to rip this autoannouncer patch only out from xeross's repo, but i happen to get a lot of extra stuff which is different aswell which has nothing to do with the autoannouncer.

Is there anyone who has a working .patch for the latest mangos. Since the old autoannouncer crashes with the new MaNGOS. (I'm sorry i s*ck with GIT :( )

Thanks on the forehand,

DarkMessiah

Link to comment
Share on other sites

Nice patch, which should be implemented to mangos imo.

This works on 9312 for me.

diff --git a/src/game/Language.h b/src/game/Language.h
index 9f9f7af..857d6b9 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -778,6 +778,8 @@ enum MangosStrings
    //                                    10000-10999

    // Use for custom patches             11000-11999
+    // Broadcaster
+    LANG_AUTO_BROADCAST                 = 11000,

    // NOT RESERVED IDS                   12000-1999999999
    // `db_script_string` table index     2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID)
diff --git a/src/game/World.cpp b/src/game/World.cpp
index ca23473..ab5edf4 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -62,6 +62,7 @@
#include "WaypointManager.h"
#include "GMTicketMgr.h"
#include "Util.h"
+#include "Language.h"

INSTANTIATE_SINGLETON_1( World );

@@ -95,6 +96,9 @@ World::World()

    m_defaultDbcLocale = LOCALE_enUS;
    m_availableDbcLocaleMask = 0;
+
+    // Initialize broadcaster nextId
+    m_nextId = 0;
}

/// World destructor
@@ -1082,6 +1086,11 @@ void World::LoadConfigSettings(bool reload)
    sLog.outString( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i",enableLOS, enableHeight);
    sLog.outString( "WORLD: VMap data directory is: %svmaps",m_dataPath.c_str());
    sLog.outString( "WORLD: VMap config keys are: vmap.enableLOS, vmap.enableHeight, vmap.ignoreMapIds, vmap.ignoreSpellIds");
+
+    // Broadcaster
+    m_configs[CONFIG_BROADCAST_ENABLED] = sConfig.GetBoolDefault("Broadcast.Enabled", true);
+    m_configs[CONFIG_BROADCAST_INTERVAL] = sConfig.GetIntDefault("Broadcast.Interval", 150000);
+    m_configs[CONFIG_BROADCAST_POSITION] = sConfig.GetIntDefault("Broadcast.Position", 1);
}

/// Initialize the World
@@ -1491,6 +1500,9 @@ void World::SetInitialWorldSettings()
    uint32 nextGameEvent = gameeventmgr.Initialize();
    m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);    //depend on next event

+    sLog.outString("Starting Autobroadcast system..." );
+    m_timers[WUPDATE_BROADCAST].SetInterval(m_configs[CONFIG_BROADCAST_INTERVAL]);
+
    sLog.outString( "WORLD: World initialized" );
}

@@ -1643,6 +1655,13 @@ void World::Update(uint32 diff)
        m_timers[WUPDATE_EVENTS].Reset();
    }

+    ///- Process autobroadcaster
+    if(getConfig(CONFIG_BROADCAST_ENABLED) && m_timers[WUPDATE_BROADCAST].Passed())
+    {
+        m_timers[WUPDATE_BROADCAST].Reset();
+        SendBroadcast();
+    }
+
    /// [/list]
    ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"
    MapManager::Instance().DoDelayedMovesAndRemoves();
@@ -2176,3 +2195,42 @@ void World::LoadDBVersion()
    if(m_CreatureEventAIVersion.empty())
        m_CreatureEventAIVersion = "Unknown creature EventAI.";
}
+
+/// Broadcast a message
+void World::SendBroadcast()
+{
+    std::string message;
+
+    QueryResult *result;
+    if(m_nextId > 0)
+        result = loginDatabase.PQuery("SELECT `text`, `next` FROM `broadcast_strings` WHERE `id` = %u;", m_nextId);
+    else
+        result = loginDatabase.PQuery("SELECT `text`, `next` FROM `broadcast_strings` ORDER BY RAND();", m_nextId);
+
+    if(!result)
+        return;
+
+    Field *fields = result->Fetch();
+    m_nextId  = fields[1].GetUInt32();
+    message = fields[0].GetString();
+
+    delete result, fields;
+
+    if((getConfig(CONFIG_BROADCAST_POSITION) & BROADCAST_LOCATION_CHAT) == BROADCAST_LOCATION_CHAT)
+        sWorld.SendWorldText(LANG_AUTO_BROADCAST, message.c_str());
+    if((getConfig(CONFIG_BROADCAST_POSITION) & BROADCAST_LOCATION_TOP) == BROADCAST_LOCATION_TOP)
+    {
+        WorldPacket data(SMSG_NOTIFICATION, (message.size()+1));
+        data << message;
+        sWorld.SendGlobalMessage(&data);
+    }
+
+    if((getConfig(CONFIG_BROADCAST_POSITION) & BROADCAST_LOCATION_IRC) == BROADCAST_LOCATION_IRC)
+#ifdef MANGCHAT_INSTALLED
+        sIRC.Send_IRC_Channel(sIRC._irc_chan[sIRC.anchn].c_str(), "\\00311[server]: " + message);
+#else
+        sLog.outError("AutoBroadcaster: You have IRC broadcasting enabled but we couldn't detect mangchat");
+#endif
+
+    sLog.outString("AutoBroadcast: '%s'",message.c_str());
+}
diff --git a/src/game/World.h b/src/game/World.h
index 74c897a..7a58e59 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -77,7 +77,8 @@ enum WorldTimers
    WUPDATE_UPTIME      = 4,
    WUPDATE_CORPSES     = 5,
    WUPDATE_EVENTS      = 6,
-    WUPDATE_COUNT       = 7
+    WUPDATE_BROADCAST   = 7,
+    WUPDATE_COUNT       = 8
};

/// Configuration elements
@@ -222,6 +223,12 @@ enum WorldConfigs
    CONFIG_TIMERBAR_BREATH_MAX,
    CONFIG_TIMERBAR_FIRE_GMLEVEL,
    CONFIG_TIMERBAR_FIRE_MAX,
+
+    // Broadcaster
+    CONFIG_BROADCAST_ENABLED,
+    CONFIG_BROADCAST_INTERVAL,
+    CONFIG_BROADCAST_POSITION,
+
    CONFIG_VALUE_COUNT
};

@@ -334,6 +341,13 @@ enum RealmZone
    REALM_ZONE_CN9           = 29                           // basic-Latin at create, any at login
};

+enum BroadcastLocation
+{
+    BROADCAST_LOCATION_CHAT = 1,
+    BROADCAST_LOCATION_TOP = 2,
+    BROADCAST_LOCATION_IRC = 4,
+};
+
// DB scripting commands
#define SCRIPT_COMMAND_TALK                  0              // source = unit, target=any, datalong ( 0=say, 1=whisper, 2=yell, 3=emote text)
#define SCRIPT_COMMAND_EMOTE                 1              // source = unit, datalong = anim_id
@@ -597,6 +611,10 @@ class World
        std::string m_DBVersion;
        std::string m_CreatureEventAIVersion;
        std::string m_ScriptsVersion;
+
+        //Broadcaster
+        uint32 m_nextId;
+        void SendBroadcast();
};

extern uint32 realmID;
diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index 479a6ce..705e28e 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -1374,3 +1374,27 @@ Ra.IP = 0.0.0.0
Ra.Port = 3443
Ra.MinLevel = 3
Ra.Secure = 1
+
+###################################################################################################################
+# Automatic Broadcaster
+#
+#    AutoBroadcast.Enabled
+#        Enable/Disable the broadcaster
+#        Default: 0 - off
+#                 1 - on
+#
+#    AutoBroadcast.Position
+#        Where to display the message (Just add the values for multiple)
+#        Default: 1 - In the in-game chat window
+#                 2 - In the top-middle of the screen
+#                 4 - In the announcements IRC channel (if mangchat is installed)
+#
+#    AutoBroadcast.Interval
+#        Interval at which to broadcast messages
+#
+###################################################################################################################
+
+AutoBroadcast.Enabled = 1
+AutoBroadcast.Position = 1
+AutoBroadcast.Interval = 30000
+

Link to comment
Share on other sites

  • 2 weeks later...

Why you replaced WUPDATE_COUNT = 7 with WUPDATE_BROADCAST = 7, and added WUPDATE_COUNT = 8 after custom WUPDATE_BROADCAST = 7?

I think

WUPDATE_EVENTS      = 6,
   WUPDATE_COUNT       = 7,
   WUPDATE_BROADCAST   = 8

is better? I'm not sure if it somehow affects the running of the script, but I think that the original takes precedence over custom script

Link to comment
Share on other sites

Why you replaced WUPDATE_COUNT = 7 with WUPDATE_BROADCAST = 7, and added WUPDATE_COUNT = 8 after custom WUPDATE_BROADCAST = 7?

I think

WUPDATE_EVENTS      = 6,
   WUPDATE_COUNT       = 7,
   WUPDATE_BROADCAST   = 8

is better? I'm not sure if it somehow affects the running of the script, but I think that the original takes precedence over custom script

No it doesn't, count indicates how many WUPDATE entries there are so if you'd swap em it would probably skip WUPDATE_BROADCAST.

Link to comment
Share on other sites

Patch for 9411 ;)

diff --git a/sql/broadcast/mangos_mangos_string.sql b/sql/broadcast/mangos_mangos_string.sql
new file mode 100644
index 0000000..ff5dc4e
--- /dev/null
+++ b/sql/broadcast/mangos_mangos_string.sql
@@ -0,0 +1 @@
+INSERT INTO `mangos_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) VALUES
(11000, '|cffffcc00[server]: |cff00ff00%s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
\\ No newline at end of file
diff --git a/sql/broadcast/realmd_broadcast_strings.sql b/sql/broadcast/realmd_broadcast_strings.sql
new file mode 100644
index 0000000..37b1813
--- /dev/null
+++ b/sql/broadcast/realmd_broadcast_strings.sql
@@ -0,0 +1,6 @@
+CREATE TABLE IF NOT EXISTS `broadcast_strings` (
+  `id` int(11) unsigned NOT NULL auto_increment,
+  `text` text NOT NULL,
+  `next` int(11) unsigned NOT NULL,
+  PRIMARY KEY  (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
\\ No newline at end of file
diff --git a/src/game/Language.h b/src/game/Language.h
index 4e03a5c..efb3547 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -832,6 +832,8 @@ enum MangosStrings
    //                                    10000-10999

    // Use for custom patches             11000-11999
+    // Broadcaster
+    LANG_AUTO_BROADCAST                 = 11000,

    // NOT RESERVED IDS                   12000-1999999999
    // `db_script_string` table index     2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID)
diff --git a/src/game/World.cpp b/src/game/World.cpp
index a9e6f4b..ee41c83 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -62,6 +62,7 @@
#include "WaypointManager.h"
#include "GMTicketMgr.h"
#include "Util.h"
+#include "Language.h"

INSTANTIATE_SINGLETON_1( World );

@@ -95,6 +96,9 @@ World::World()

    m_defaultDbcLocale = LOCALE_enUS;
    m_availableDbcLocaleMask = 0;
+
+    // Initialize broadcaster nextId
+    m_nextId = 0;

   for(int i = 0; i < CONFIG_UINT32_VALUE_COUNT; ++i)
       m_configUint32Values[i] = 0;
@@ -1100,6 +1104,11 @@ void World::LoadConfigSettings(bool reload)
    sLog.outString( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i",enableLOS, enableHeight);
    sLog.outString( "WORLD: VMap data directory is: %svmaps",m_dataPath.c_str());
    sLog.outString( "WORLD: VMap config keys are: vmap.enableLOS, vmap.enableHeight, vmap.ignoreMapIds, vmap.ignoreSpellIds");
+
+    // Broadcaster
+    setConfig(CONFIG_UINT32_BROADCAST_ENABLED, "Broadcast.Enabled", true);
+    setConfig(CONFIG_UINT32_BROADCAST_INTERVAL, "Broadcast.Interval", 150000);
+    setConfig(CONFIG_UINT32_BROADCAST_POSITION, "Broadcast.Position", 1);
}

/// Initialize the World
@@ -1523,6 +1532,9 @@ void World::SetInitialWorldSettings()
    uint32 nextGameEvent = sGameEventMgr.Initialize();
    m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);    //depend on next event

+    sLog.outString("Starting Autobroadcast system..." );
+    m_timers[WUPDATE_BROADCAST].SetInterval(m_configUint32Values[CONFIG_UINT32_BROADCAST_INTERVAL]);
+
    sLog.outString( "WORLD: World initialized" );

    uint32 uStartInterval = getMSTimeDiff(uStartTime, getMSTime());
@@ -1678,6 +1690,13 @@ void World::Update(uint32 diff)
        m_timers[WUPDATE_EVENTS].Reset();
    }

+    ///- Process autobroadcaster
+    if(getConfig(CONFIG_UINT32_BROADCAST_ENABLED) && m_timers[WUPDATE_BROADCAST].Passed())
+    {
+        m_timers[WUPDATE_BROADCAST].Reset();
+        SendBroadcast();
+    }
+
    /// [/list]
    ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"
    sMapMgr.DoDelayedMovesAndRemoves();
@@ -2207,3 +2226,42 @@ void World::LoadDBVersion()
    if(m_CreatureEventAIVersion.empty())
        m_CreatureEventAIVersion = "Unknown creature EventAI.";
}
+
+/// Broadcast a message
+void World::SendBroadcast()
+{
+    std::string message;
+
+    QueryResult *result;
+    if(m_nextId > 0)
+        result = loginDatabase.PQuery("SELECT `text`, `next` FROM `broadcast_strings` WHERE `id` = %u;", m_nextId);
+    else
+        result = loginDatabase.PQuery("SELECT `text`, `next` FROM `broadcast_strings` ORDER BY RAND();", m_nextId);
+
+    if(!result)
+        return;
+
+    Field *fields = result->Fetch();
+    m_nextId  = fields[1].GetUInt32();
+    message = fields[0].GetString();
+
+    delete result, fields;
+
+    if((getConfig(CONFIG_UINT32_BROADCAST_POSITION) & BROADCAST_LOCATION_CHAT) == BROADCAST_LOCATION_CHAT)
+        sWorld.SendWorldText(LANG_AUTO_BROADCAST, message.c_str());
+    if((getConfig(CONFIG_UINT32_BROADCAST_POSITION) & BROADCAST_LOCATION_TOP) == BROADCAST_LOCATION_TOP)
+    {
+        WorldPacket data(SMSG_NOTIFICATION, (message.size()+1));
+        data << message;
+        sWorld.SendGlobalMessage(&data);
+    }
+
+    if((getConfig(CONFIG_UINT32_BROADCAST_POSITION) & BROADCAST_LOCATION_IRC) == BROADCAST_LOCATION_IRC)
+#ifdef MANGCHAT_INSTALLED
+        sIRC.Send_IRC_Channel(sIRC._irc_chan[sIRC.anchn].c_str(), "\\00311[server]: " + message);
+#else
+        sLog.outError("AutoBroadcaster: You have IRC broadcasting enabled but we couldn't detect mangchat");
+#endif
+
+    sLog.outString("AutoBroadcast: '%s'",message.c_str());
+}
\\ No newline at end of file
diff --git a/src/game/World.h b/src/game/World.h
index 170fc2a..12e20bd 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -77,7 +77,8 @@ enum WorldTimers
    WUPDATE_UPTIME      = 4,
    WUPDATE_CORPSES     = 5,
    WUPDATE_EVENTS      = 6,
-    WUPDATE_COUNT       = 7
+    WUPDATE_BROADCAST   = 7,
+    WUPDATE_COUNT       = 8
};

/// Configuration elements
@@ -222,6 +223,12 @@ enum WorldConfigs
    CONFIG_UINT32_TIMERBAR_BREATH_MAX,
    CONFIG_UINT32_TIMERBAR_FIRE_GMLEVEL,
    CONFIG_UINT32_TIMERBAR_FIRE_MAX,
+    
+    // Broadcaster
+    CONFIG_UINT32_BROADCAST_ENABLED,
+    CONFIG_UINT32_BROADCAST_INTERVAL,
+    CONFIG_UINT32_BROADCAST_POSITION,
+    
    CONFIG_UINT32_VALUE_COUNT
};

@@ -334,6 +341,13 @@ enum RealmZone
    REALM_ZONE_CN9           = 29                           // basic-Latin at create, any at login
};

+enum BroadcastLocation
+{
+    BROADCAST_LOCATION_CHAT = 1,
+    BROADCAST_LOCATION_TOP = 2,
+    BROADCAST_LOCATION_IRC = 4,
+};
+
// DB scripting commands
#define SCRIPT_COMMAND_TALK                  0              // source = unit, target=any, datalong ( 0=say, 1=whisper, 2=yell, 3=emote text)
#define SCRIPT_COMMAND_EMOTE                 1              // source = unit, datalong = anim_id
@@ -597,6 +611,10 @@ class World
        std::string m_DBVersion;
        std::string m_CreatureEventAIVersion;
        std::string m_ScriptsVersion;
+
+        //Broadcaster
+        uint32 m_nextId;
+        void SendBroadcast();
};

extern uint32 realmID;
diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index 479a6ce..126e4ca 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -1374,3 +1374,26 @@ Ra.IP = 0.0.0.0
Ra.Port = 3443
Ra.MinLevel = 3
Ra.Secure = 1
+
+###################################################################################################################
+# Automatic Broadcaster
+#
+#    AutoBroadcast.Enabled
+#        Enable/Disable the broadcaster
+#        Default: 0 - off
+#                 1 - on
+#
+#    AutoBroadcast.Position
+#        Where to display the message (Just add the values for multiple)
+#        Default: 1 - In the in-game chat window
+#                 2 - In the top-middle of the screen
+#                 4 - In the announcements IRC channel (if mangchat is installed)
+#
+#    AutoBroadcast.Interval
+#        Interval at which to broadcast messages
+#
+###################################################################################################################
+
+Broadcast.Enabled = 1
+Broadcast.Position = 2
+Broadcast.Interval = 30000

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use