Hello & Welcome to our community. Is this your first visit? Register
Follow us on
Follow us on Facebook Follow us on Twitter Watch us on YouTube


MMOCoin

Likes Likes:  0
Results 1 to 5 of 5
  1. #1
    Grunt
    Sdyess94's Avatar
    Join Date
    Jan 2009
    Posts
    36
    Post Thanks / Like
    Rep Power
    16
    Reputation
    60

    [C++/ArcEmu] Donor Announce and Server Chat


    Register to remove this ad
    Here is a patch that I've made.

    Firstly, make sure you have enabled Player Commands in the config file.

    The .donorannounce command, is similar to the gamemaster announce command. Anyone that had permissions 'd' will see it. So most gamemasters and admins should see it, but player's won't. I should've added some color, but oh well.

    Secondly, there is a server wide chat. It's fairly basic, and I plan to improve it when I get some time.

    This includes 3 commands.

    1. .chat - Can be used by players to broadcast a message to everyone.
    2 .mute <name> - Mutes the listed player
    3 .unmute <name> - Unmutes the player.

    Again, should've added some color, but oh well.



    Enjoy

    Code:
    Index: src/arcemu-world/Chat.cpp
    ===================================================================
    --- src/arcemu-world/Chat.cpp    (revision 3274)
    +++ src/arcemu-world/Chat.cpp    (working copy)
    @@ -224,6 +224,8 @@
     
     void CommandTableStorage::Init()
     {
    +
    +
         static ChatCommand modifyCommandTable[] =
         {
             { "hp",              'm', NULL,                                   "Modifies health points (HP) of selected target",                  NULL, UNIT_FIELD_HEALTH,                 UNIT_FIELD_MAXHEALTH, 1 },
    @@ -698,7 +700,10 @@
     
         static ChatCommand commandTable[] =
         {
    +        { "mute",            'c', &ChatHandler::HandleMuteCommand,                          "",                                                                                                          NULL,                     0, 0, 0 },
    +        { "unmute",          'c', &ChatHandler::HandleUnMuteCommand,                        "",                                                                                                                    NULL,                     0, 0, 0 },
             { "commands",        '0', &ChatHandler::HandleCommandsCommand,                      "Shows commands",                                                                                                                          NULL,                     0, 0, 0 },
    +        { "chat",            '0', &ChatHandler::HandleSpeakCommand,                         "",                                                                                                                      NULL,                     0, 0, 0 },
             { "help",            '0', &ChatHandler::HandleHelpCommand,                          "Shows help for command",                                                                                                                  NULL,                     0, 0, 0 },
             { "calcdist",        '0', &ChatHandler::HandleSimpleDistanceCommand,                "Display the distance between your current position and the specified point x y z",                                                           NULL,                     0, 0, 0 },
             { "announce",        'u', &ChatHandler::HandleAnnounceCommand,                      "Sends a normal chat message broadcast to all players.",                                                                                                                        NULL,                     0, 0, 0 },
    @@ -757,6 +762,7 @@
             { "fixscale",        'm', &ChatHandler::HandleFixScaleCommand,                      "",                                                                                                                                        NULL,                     0, 0, 0 },
             { "addtrainerspell", 'm', &ChatHandler::HandleAddTrainerSpellCommand,               "",                                                                                                                                        NULL,                     0, 0, 0 },
             { "achieve",         '0', NULL,                                                     "",                                                                                                                                        achievementCommandTable,  0, 0, 0 },
    +        { "donorannounce",   'd', &ChatHandler::HandleDonorAnnounceCommand,                 "",                                                                                                                                        NULL,                     0, 0, 0 },
             { NULL,              '0', NULL,                                                     "",                                                                                                                                        NULL,                     0, 0, 0 }
         };
         dupe_command_table(commandTable, _commandTable);
    Index: src/arcemu-world/Chat.h
    ===================================================================
    --- src/arcemu-world/Chat.h    (revision 3274)
    +++ src/arcemu-world/Chat.h    (working copy)
    @@ -231,6 +231,10 @@
         ChatCommand* getCommandTable();
     
         // Level 0 commands
    +    bool HandleSpeakCommand(const char* args, WorldSession *m_session);
    +    bool HandleMuteCommand(const char* args, WorldSession *m_session);
    +    bool HandleUnMuteCommand(const char* args, WorldSession *m_ession);
    +    bool HandleDonorAnnounceCommand(const char* args, WorldSession *m_session);
         bool HandleHelpCommand(const char* args, WorldSession *m_session);
         bool HandleCommandsCommand(const char* args, WorldSession *m_session);
         bool HandleNYICommand(const char* args, WorldSession *m_session);
    @@ -529,6 +533,8 @@
         bool HandleGlobalPlaySoundCommand(const char* args, WorldSession * m_session);
         bool HandleRecallPortPlayerCommand(const char* args, WorldSession * m_session);
         bool HandleRecallPortUsCommand(const char* args, WorldSession * m_session);
    +    
    +    //Donor Commands
     
         // Bans
         bool HandleIPBanCommand(const char * args, WorldSession * m_session);
    Index: src/arcemu-world/Level0.cpp
    ===================================================================
    --- src/arcemu-world/Level0.cpp    (revision 3274)
    +++ src/arcemu-world/Level0.cpp    (working copy)
    @@ -56,6 +56,53 @@
         return false;
     }
     
    +bool MuteCheck(WorldSession *m_session)
    +{
    +    QueryResult * IfMute = CharacterDatabase.Query("SELECT * FROM chatban WHERE GUID='%u';", m_session->GetPlayer()->GetGUID());
    +    if(IfMute != NULL)
    +        return true;
    +    else
    +        return false;
    +    IfMute->Delete();
    +}
    +
    +
    +bool ChatHandler::HandleSpeakCommand(const char* args, WorldSession *m_session)
    +{
    +    if(!args)
    +        return false;
    +    if(MuteCheck(m_session) == true)
    +    {
    +        m_session->GetPlayer()->BroadcastMessage("You are banned from the chat command.");
    +        return false;
    +    }
    +    
    +    char sAnnounce[1024];
    +    string pname = m_session->GetPlayer()->GetName();
    +    string pinput;
    +
    +    pinput += "[Chat]";
    +    if(m_session->CanUseCommand('z'))
    +    {
    +        pinput += "[A]";
    +    }
    +    else if(m_session->CanUseCommand('a'))
    +    {
    +        pinput += "[GM]";
    +    }
    +    else if(m_session->CanUseCommand('d')
    +    {
    +        pinput += "[D]";
    +    }
    +    else
    +    {
    +        pinput += "[P]";
    +    }
    +    pinput += "[" + pname + "]: ";
    +    snprintf((char*)sAnnounce, 1024, "%s%s", pinput.c_str(), args);
    +    sWorld.SendWorldText(sAnnounce);
    +    return true;
    +}
     bool ChatHandler::HandleHelpCommand(const char* args, WorldSession *m_session)
     {
     //    ChatCommand *table = getCommandTable();
    Index: src/arcemu-world/Level1.cpp
    ===================================================================
    --- src/arcemu-world/Level1.cpp    (revision 3274)
    +++ src/arcemu-world/Level1.cpp    (working copy)
    @@ -54,6 +54,59 @@
         return (ptr-itemlink) & 0x0000ffff;
     }
     
    +bool ChatHandler::HandleUnMuteCommand(const char* args, WorldSession *m_session)
    +{
    +    if(!args)
    +        return false;
    +    char *pname = strtok((char*)args, " ");
    +    if(!pname)
    +    {
    +        RedSystemMessage(m_session, "No name specified.");
    +        return true;
    +    }
    +    Player *chr = objmgr.GetPlayer((const char*)pname, false);
    +    if(chr == NULL)
    +    {
    +        RedSystemMessage(m_session, "Player does not exist or is offline.");
    +        return true;
    +    }
    +    else
    +    {
    +        CharacterDatabase.Execute("DELETE FROM chatban WHERE GUID='%u'", chr->GetGUID());
    +        SystemMessageToPlr(chr, "You are being unmuted from the chat by %s.", m_session->GetPlayer()->GetName());
    +    }
    +    return true;
    +}
    +
    +bool ChatHandler::HandleMuteCommand(const char *args, WorldSession *m_session)
    +{
    +    if(!args)
    +        return false;
    +    char *pname = strtok((char*)args, " ");
    +    if(!pname)
    +    {
    +        RedSystemMessage(m_session, "No name specified.");
    +        return true;
    +    }
    +    Player *chr = objmgr.GetPlayer((const char*)pname, false);
    +    if(chr == NULL)
    +    {
    +        RedSystemMessage(m_session, "Player does not exist or is offline.");
    +        return true;
    +    }
    +    else
    +    {
    +        CharacterDatabase.Execute("INSERT INTO chatban VALUES('%u')", chr->GetGUID());
    +        char msg[200];
    +        snprintf(msg, 200, "%sNOTICE: %s was muted from the chat by %s.", MSG_COLOR_RED, chr->GetName(), m_session->GetPlayer()->GetName());
    +        sWorld.SendWorldText(msg, NULL);
    +        //sWorld.SendIRCMessage(msg);
    +        SystemMessageToPlr(chr, "You are being muted from the chat by %s.", m_session->GetPlayer()->GetName());
    +    }
    +    return true;
    +    
    +}
    +
     bool ChatHandler::HandleAnnounceCommand(const char* args, WorldSession *m_session)
     {
         if( !*args || strlen(args) < 4 || strchr(args, '%'))
    @@ -88,7 +141,19 @@
         sGMLog.writefromsession(m_session, "used announce command, [%s]", args);
         return true;
     }
    +bool ChatHandler::HandleDonorAnnounceCommand(const char* args, WorldSession *m_session)
    +{
    +    if(!*args)
    +        return false;
    +    char donorannounce[1000];
    +    snprintf(donorannounce, 1000, "[Donor][%s]: %s", m_session->GetPlayer()->GetName(), args);
    +    sGMLog.writefromsession(m_session, "used donor announce command, [%s]", args);
    +    sWorld.SendDonorText(donorannounce);
    +    return true;
     
    +}
    +
    +
     bool ChatHandler::HandleGMAnnounceCommand(const char* args, WorldSession *m_session)
     {
         if(!*args)
    @@ -162,7 +227,7 @@
     bool ChatHandler::HandleGMOffCommand(const char* args, WorldSession *m_session)
     {
     
    -    GreenSystemMessage(m_session, "Unsetting GM Flag on yourself...");
    +    GreenSystemMessage(m_session, "Disabling Gamemaster Flag...");
     
         Player * _player = m_session->GetPlayer();
         if(!_player->bGMTagOn)
    @@ -175,7 +240,7 @@
             _player->SetFaction( _player->GetInitialFactionId() );
             _player->UpdatePvPArea();
     
    -        BlueSystemMessage(m_session, "GM Flag Removed. <GM> Will no longer show in chat messages or above your name.");
    +        BlueSystemMessage(m_session, "The Gamemaster flag has been removed. You will no longer be affected by <GM>.");
     
             _player->UpdateVisibility();
         }
    Index: src/arcemu-world/World.cpp
    ===================================================================
    --- src/arcemu-world/World.cpp    (revision 3274)
    +++ src/arcemu-world/World.cpp    (working copy)
    @@ -654,6 +654,22 @@
         m_sessionlock.ReleaseReadLock();
     }
     
    +void World::SendDonorMessage(WorldPacket *packet, WorldSession *self)
    +{
    +    m_sessionlock.AcquireReadLock();
    +    SessionMap::iterator itr;
    +    for(itr = m_sessions.begin(); itr != m_sessions.end(); itr++)
    +    {
    +      if (itr->second->GetPlayer() &&
    +      itr->second->GetPlayer()->IsInWorld()
    +      && itr->second != self)  // don't send to self!
    +      {
    +        if(itr->second->CanUseCommand('d'))
    +        itr->second->SendPacket(packet);
    +      }
    +    }
    +    m_sessionlock.ReleaseReadLock();
    +}
     void World::SendGamemasterMessage(WorldPacket *packet, WorldSession *self)
     {
         m_sessionlock.AcquireReadLock();
    @@ -753,6 +769,26 @@
         SendGamemasterMessage(&data, self);
     }
     
    +void World::SendDonorText(const char* text, WorldSession *self)
    +{
    +    uint32 textLen = (uint32)strlen((char*)text) + 1;
    +
    +    WorldPacket data(textLen + 40);
    +
    +    data.Initialize(SMSG_MESSAGECHAT);
    +    data << uint8(CHAT_MSG_SYSTEM);
    +    data << uint32(LANG_UNIVERSAL);
    +    
    +    data << (uint64)0;
    +    data << (uint32)0;
    +    data << (uint64)0;
    +
    +    data << textLen;
    +    data << text;
    +    data << uint8(0);
    +    SendDonorMessage(&data, self);
    +}
    +
     void World::SendWorldWideScreenText(const char *text, WorldSession *self)
     {
         WorldPacket data(256);
    Index: src/arcemu-world/World.h
    ===================================================================
    --- src/arcemu-world/World.h    (revision 3274)
    +++ src/arcemu-world/World.h    (working copy)
    @@ -331,7 +331,9 @@
         ARCEMU_INLINE time_t GetGameTime() const { return m_gameTime; }
     
         bool SetInitialWorldSettings();
    -
    +    
    +    void SendDonorText(const char *text, WorldSession *self = 0);
    +    void SendDonorMessage(WorldPacket *packet, WorldSession *self = 0);
         void SendWorldText(const char *text, WorldSession *self = 0);
         void SendWorldWideScreenText(const char *text, WorldSession *self = 0);
         void SendGlobalMessage(WorldPacket *packet, WorldSession *self = 0);
    And here's the SQL. Be sure to execute it in your character database.
    Code:
    CREATE TABLE `chatban` (
      `GUID` int(11) NOT NULL,
      PRIMARY KEY  (`GUID`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;



    › See More: [C++/ArcEmu] Donor Announce and Server Chat



  2. Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread

  3. #2
    Contributor
    StickyIcky's Avatar
    Join Date
    Jul 2008
    Location
    127.0.0.1
    Posts
    747
    Post Thanks / Like
    Rep Power
    19
    Reputation
    188
    Very Nice

    Mind if I edit this to add some color and extra features? Will give credits.


  4. #3
    Grunt
    Sdyess94's Avatar
    Join Date
    Jan 2009
    Posts
    36
    Post Thanks / Like
    Rep Power
    16
    Reputation
    60
    Sure, I just never got around to adding colors, it would look a lot better with it though.

  5. #4
    Elite Member
    Dimman's Avatar
    Join Date
    Apr 2009
    Posts
    1,091
    Post Thanks / Like
    Rep Power
    21
    Reputation
    319
    Nice, good job Sdy i will +Rep you when i can ( need 2 spread) -.- ^^
    No touching please.

  6. #5
    Senior Sergeant
    MikExV™'s Avatar
    Join Date
    Feb 2010
    Location
    Ohio
    Posts
    117
    Post Thanks / Like
    Rep Power
    15
    Reputation
    35

    Register to remove this ad
    Nice Tested it on my server works great.

    Just got my pc back

 

 

Visitors found this page by searching for:

how make .chat in arcemu

download .chat arcemu wow

c arcemu chat log

announce wow arcemu

c chat server

announce for server arcemu

general chat arcemu color

.chat trinity wow

arcemu announce

chat C

modifying c in arcemu

c++ Announce

arcemu announce colors

trinity c donor

arcemu adding donor points

download arcemu c announcer wow

Arcemu o chat

arcemu annouce message

if(m_session-&gt;CanUseCommand(z)) arcemu

else if(m_session-&gt;CanUseCommand

SEO Blog

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -5. The time now is 06:59 PM.
Powered by vBulletin® Copyright ©2000-2024, Jelsoft Enterprises Ltd.
See More links by ForumSetup.net. Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
vBulletin Licensed to: MMOPro.org