Jump to content

[Patch] Auto Announcer(With Next ID)


Recommended Posts

In your realmd DB you have a table caled autobroadcast

It looks like this

Lets say you want 3 mesage to broadcast

message 1

message 2

message 3

I think you can understend now how it works,

yeah thanks for your annswer and for this patch.

Link to comment
Share on other sites

  • Replies 64
  • Created
  • Last Reply

Top Posters In This Topic

Hi

I installed this patch and at first i left the timer at default 30000 and that was to fast. after that i changed the timer to 60000 and the messages appeared with the same delay like on 30000.

I want to set the announcements to 1 H delay .

Can someone tell me how to do that.

Ty

Link to comment
Share on other sites

Thanks, good job.

I' ve just a problem. When i just use this patch, it work well.

But when i use it with this other:

git pull git://github.com/Naicisum/mangos.git ahbot

I have a conglict (content): Merge conflict in src/game/World.cpp

Can you help me please? What can i do to fix that conflict?

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

I have updated autobroadcast to match the revision 8893.

Here is a git diff patch file:

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
@@ -823,6 +823,8 @@ enum MangosStrings
    // Room for more debug                1202-1299 not used

    // FREE IDS                           1300-9999
+    // Broadcaster
+    LANG_AUTO_BROADCAST                 = 1300,

    // Use for not-in-offcial-sources patches
    //                                    10000-10999
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
@@ -49,6 +49,7 @@
#include "CreatureAIRegistry.h"
#include "Policies/SingletonImp.h"
#include "BattleGroundMgr.h"
+#include "Language.h"
#include "TemporarySummon.h"
#include "WaypointMovementGenerator.h"
#include "VMapFactory.h"
@@ -1462,8 +1463,10 @@ void World::SetInitialWorldSettings()
    sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d",
        local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);

-    loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)",
-        realmID, uint64(m_startTime), isoDate);
+    loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)", realmID, uint64(m_startTime), isoDate);
+
+    static uint32 abtimer = 0;
+    abtimer = sConfig.GetIntDefault("AutoBroadcast.Timer", 60000);

    m_timers[WUPDATE_OBJECTS].SetInterval(0);
    m_timers[WUPDATE_SESSIONS].SetInterval(0);
@@ -1473,7 +1476,8 @@ void World::SetInitialWorldSettings()
                                                            //Update "uptime" table based on configuration entry in minutes.
    m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*IN_MILISECONDS);
                                                            //erase corpses every 20 minutes
-
+    m_timers[WUPDATE_AUTOBROADCAST].SetInterval(abtimer);
+    
    //to set mailtimer to return mails every day between 4 and 5 am
    //mailtimer is increased when updating auctions
    //one second is 1000 -(tested on win system)
@@ -1513,6 +1517,8 @@ void World::SetInitialWorldSettings()
    uint32 nextGameEvent = sGameEventMgr.Initialize();
    m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);    //depend on next event

+    sLog.outString("Starting Autobroadcast system..." );
+    
    sLog.outString( "WORLD: World initialized" );

    uint32 uStartInterval = getMSTimeDiff(uStartTime, getMSTime());
@@ -1667,6 +1673,16 @@ void World::Update(uint32 diff)
        m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);
        m_timers[WUPDATE_EVENTS].Reset();
    }
+    static uint32 autobroadcaston = 0;
+    autobroadcaston = sConfig.GetIntDefault("AutoBroadcast.On", 0);
+    if(autobroadcaston == 1)
+    {
+        if (m_timers[WUPDATE_AUTOBROADCAST].Passed())
+        {
+           m_timers[WUPDATE_AUTOBROADCAST].Reset();
+            SendBroadcast();
+       }
+    }

    /// [/list]
    ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"
@@ -2079,6 +2095,57 @@ void World::ProcessCliCommands()
        zprint("mangos>");
}

+void World::SendBroadcast()
+{
+    std::string msg;
+    static int nextid;
+
+    QueryResult *result;
+    if(nextid != 0)
+    {
+        result = loginDatabase.PQuery("SELECT `text`, `next` FROM `autobroadcast` WHERE `id` = %u", nextid);
+    }
+    else
+    {
+        result = loginDatabase.PQuery("SELECT `text`, `next` FROM `autobroadcast` ORDER BY RAND() LIMIT 1");
+    }
+
+    if(!result)
+        return;
+
+    Field *fields = result->Fetch();
+    nextid  = fields[1].GetUInt32();
+    msg = fields[0].GetString();
+    delete result;
+
+    static uint32 abcenter = 0;
+    abcenter = sConfig.GetIntDefault("AutoBroadcast.Center", 0);
+    if(abcenter == 0)
+    {
+        sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
+
+        sLog.outString("AutoBroadcast: '%s'",msg.c_str());
+    }
+    if(abcenter == 1)
+    {
+        WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1));
+        data << msg;
+        sWorld.SendGlobalMessage(&data);
+
+        sLog.outString("AutoBroadcast: '%s'",msg.c_str());
+    }
+    if(abcenter == 2)
+    {
+        sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
+
+        WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1));
+        data << msg;
+        sWorld.SendGlobalMessage(&data);
+
+        sLog.outString("AutoBroadcast: '%s'",msg.c_str());
+   }
+}
+
void World::InitResultQueue()
{
    m_resultQueue = new SqlResultQueue;
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_AUTOBROADCAST = 7,
+    WUPDATE_COUNT         = 8
};

/// Configuration elements
@@ -383,6 +384,7 @@ class World

        WorldSession* FindSession(uint32 id) const;
        void AddSession(WorldSession *s);
+        void SendBroadcast();
        bool RemoveSession(uint32 id);
        /// Get the number of current active sessions
        void UpdateMaxSessionCounters();
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
@@ -734,6 +734,25 @@ AllowTwoSide.AddFriend = 0
TalentsInspecting = 1

###################################################################################################################
+# AUTO BROADCAST
+#    AutoBroadcast.On
+#        Enable auto broadcast
+#        Default: 0 - off
+#                 1 - on
+#    AutoBroadcast.Center
+#        Display method
+#        Default: 0 - announce
+#                 1 - notify
+#                 2 - both
+#    AutoBroadcast.Timer
+#        Timer for auto broadcast
+##################################################################################################################
+
+AutoBroadcast.On = 1
+AutoBroadcast.Center = 2
+AutoBroadcast.Timer = 30000
+
+###################################################################################################################
# CREATURE SETTINGS
#
#    ThreatRadius

Link to comment
Share on other sites

  • 3 weeks later...
Guest
This topic is now closed to further replies.
×
×
  • 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