Jump to content

[PATCH] External Mail from SQL


Recommended Posts

Oops , that sh*t dont work :( , and For example, to get http://github.com/xeross/mangos/comm...77704dfed59a99 you can do:

git remote add -f xeross git://github.com/xeross/mangos.git

git cherry-pick 5e4351fcb07dd35fb0cebafe6377704dfed59a99

Dont work , it only works if you didnt have any custom commits made like Scriptdev2 and dualspecs, i think the reason is the dual spec patch but im not sure :(

I really need this one :)

Link to comment
Share on other sites

  • Replies 104
  • Created
  • Last Reply

Top Posters In This Topic

I was wondering, Is there a way to make it send even if there offline i see the code but i do not want to edit the wrong thing. Personally i do not see a safety issue with mailing something even if there offline. It wont really harm anything considering you can mail things to characters offline anyways...

Link to comment
Share on other sites

  • 3 weeks later...

Hello everybody. Need some help with 'mass mail'. I need to send mail to many players(let's say 50) and have there names in needed easy format.

Getting `guid` from name i solved with

Select  `guid` from `characters` where `name` IN (name1, name2, name3, ...)

But got a problem with executing sql command. It simply insert only 1 row(only for name1) but I need for many names(name1, name2, name3, ...). I din't use `id` cuz it filled by self.

INSERT INTO `mail_external`( `receiver`, `subject`, `message`, `money`, `item`,  `item_count`)  VALUES
((Select  `guid` from `characters` where ( characters.name  IN ('name1', 'name2', 'name3')) ),
'message',
'text',
1,
0,
0)

Any ideas how to solve it.

Sory for my very bad English, hope you understand my problem and help me.

Link to comment
Share on other sites

DROP TABLE IF EXISTS `mail_external`;
CREATE TABLE `mail_external` (
 `id` int(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 `receiver` bigint(20) UNSIGNED NOT NULL,
 `subject` varchar(200) DEFAULT 'Support Message',
 `message` varchar(500) DEFAULT 'Support Message',
 `money` int(20) UNSIGNED NOT NULL DEFAULT '0',
 `item` int(20) UNSIGNED NOT NULL DEFAULT '0',
 `item_count` int(20) UNSIGNED NOT NULL DEFAULT '1',
 PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

no changes^( Still auto replace into 0 after entering name

Link to comment
Share on other sites

  • 2 weeks later...

Can someone please try to update this, i have been trying to update it for the latest rev but im getting a error i have no clue how to fix. Ive been able to update is just fine till recently..

Unresolved overloaded function type>[eConfigUint32Values] for array subscript

Someone please reply and say you know wtf is wrong it it, its the only error i have left for it.

Link to comment
Share on other sites

Anyone..?

I have changed the Enums to the new types, and changed how it gets the config values to the new type as well. The code itself does not report an error, but that does. So its obviously linked to how it configs but i cant figure it out considering i updated it to the new type.

Link to comment
Share on other sites

  • 4 weeks later...

This is not working with the 3.3.3a release.

void WorldSession::SendExternalMails()
{
   sLog.outString("EXTERNAL MAIL> Send Mails from Queue...");
   QueryResult *result = CharacterDatabase.Query("SELECT id,receiver,subject,message,money,item,item_count FROM mail_external");
       if(!result)
       {
          sLog.outString("EXTERNAL MAIL> No Mails in Queue...");
          delete result;
          return;
       }else{
          do{
              Field *fields = result->Fetch();
              uint32 id = fields[0].GetUInt32();
              uint64 receiver_guid = fields[1].GetUInt64();
              std::string subject = fields[2].GetString();
              std::string message = fields[3].GetString();
              uint32 money = fields[4].GetUInt32();
              uint32 ItemID = fields[5].GetUInt32();
              uint32 ItemCount = fields[6].GetUInt32();

              Player *receiver = sObjectMgr.GetPlayer( receiver_guid );

              if( receiver != 0 )
              {
                  sLog.outString("EXTERNAL MAIL> Sending mail to %u, Item:%u", receiver_guid, ItemID);

                  uint32 itemTextId = !message.empty() ? sObjectMgr.CreateItemText( message ) : 0;

                  if ( ItemID != 0 )
                  {
                      Item* ToMailItem = Item::CreateItem( ItemID, ItemCount, receiver );
                      ToMailItem -> SaveToDB();

                      MailDraft( subject, itemTextId )
                          .AddItem( ToMailItem )
                          .AddMoney( money )
                          .SendMailTo( MailReceiver(receiver), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
                  }
                  else
                  {
                      MailDraft( subject, itemTextId )
                          .AddMoney( money )
                          .SendMailTo( MailReceiver(receiver), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);

                  }
                  CharacterDatabase.PExecute("DELETE FROM mail_external WHERE id=%u", id);
              }
              else
                  sLog.outString("EXTERNAL MAIL> Player %u not in game, skip mail!", receiver_guid);

          }while( result -> NextRow() );
      }
  delete result;
  sLog.outString("EXTERNAL MAIL> All Mails Sent...");    
}

It gives these errors on compiling:

Error    1    error C2660: 'ObjectMgr::CreateItemText' : function does not take 1 arguments    d:\\SVN\\MaNGOS\\src\\game\\Mail.cpp    1110    game
Error    2    error C2665: 'MailDraft::MailDraft' : none of the 3 overloads could convert all the argument types    d:\\SVN\\MaNGOS\\src\\game\\Mail.cpp    1117    game
Error    3    error C2228: left of '.AddItem' must have class/struct/union    d:\\SVN\\MaNGOS\\src\\game\\Mail.cpp    1117    game
Error    4    error C2228: left of '.AddMoney' must have class/struct/union    d:\\SVN\\MaNGOS\\src\\game\\Mail.cpp    1117    game
Error    5    error C2228: left of '.SendMailTo' must have class/struct/union    d:\\SVN\\MaNGOS\\src\\game\\Mail.cpp    1117    game
Error    6    error C2665: 'MailDraft::MailDraft' : none of the 3 overloads could convert all the argument types    d:\\SVN\\MaNGOS\\src\\game\\Mail.cpp    1124    game
Error    7    error C2228: left of '.AddMoney' must have class/struct/union    d:\\SVN\\MaNGOS\\src\\game\\Mail.cpp    1124    game
Error    8    error C2228: left of '.SendMailTo' must have class/struct/union    d:\\SVN\\MaNGOS\\src\\game\\Mail.cpp    1124    game

Any tips?

Link to comment
Share on other sites

This is going to come out rude but im not trying to be. But if we wanted to use the SOAP interface we would already be using it, i like dealing with mail via mysql better. I have been updating this patch myself for a while but almost everything is changed and screwing with it now.

If im able to figure this out ill post a updated version..

Link to comment
Share on other sites

Thanks i don't get the std:: stuff. else I could be abled to fix it.

Error    1    error C2660: 'ObjectMgr::CreateItemText' : function does  not take 1 arguments    d:\\SVN\\MaNGOS\\src\\game\\Mail.cpp    1110    game

It says it needs more than 1 argument in the error. but the method says:

uint32 CreateItemText (std::string text)

This looks as 1 argument to me, correct me if i'm wrong.

EDIT:

When i change: MailDraft( subject, itemTextId ) to MailDraft( subject, 0 ), we just get that one error.

Link to comment
Share on other sites

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