本文整理汇总了C++中MailSender函数的典型用法代码示例。如果您正苦于以下问题:C++ MailSender函数的具体用法?C++ MailSender怎么用?C++ MailSender使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MailSender函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MailDraft
/*
* Processes the external mail queue
*/
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;
}
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();
if (Player *receiver = sObjectMgr.GetPlayer(receiver_guid))
{
sLog.outString("<EXTERNAL MAIL> Sending mail to %u, Item: %u", receiver_guid, ItemID);
if (ItemID && ItemCount < 1)
{
sLog.outString("<EXTERNAL MAIL> Warning: invalid ItemCount of %u, setting to 1", ItemCount);
ItemCount = 1;
}
Item* ToMailItem = ItemID ? Item::CreateItem(ItemID, ItemCount, receiver) : NULL;
if (ToMailItem)
{
ToMailItem->SaveToDB();
MailDraft(subject, message)
.AddItem(ToMailItem)
.SetMoney(money)
.SendMailTo(MailReceiver(receiver), MailSender(MAIL_NORMAL, uint32(0), MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
}
else
{
MailDraft(subject, message)
.SetMoney(money)
.SendMailTo(MailReceiver(receiver), MailSender(MAIL_NORMAL, uint32(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.");
}
开发者ID:mfooo,项目名称:Test,代码行数:60,代码来源:Mail.cpp
示例2: SaveToDB
void WorldSession::SendExternalMails()
{
sLog.outDebug("External Mail - Send Mails from Queue...");
QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT id,receiver,subject,message,money,item,item_count FROM mail_external");
if (!result)
{
sLog.outDebug("External Mail - No Mails in Queue...");
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 = objmgr.GetPlayer(receiver_guid);
if (receiver != 0)
{
sLog.outDebug("External Mail - Sending mail to %llu, Item:%u", receiver_guid, ItemID);
uint32 itemTextId = !message.empty() ? objmgr.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);
}
}
while(result -> NextRow());
}
sLog.outDebug("External Mail - All Mails Sent...");
}
开发者ID:Anonymus123,项目名称:AtomicCore-2.4.3,代码行数:51,代码来源:Mail.cpp
示例3: GetTaskValue
bool GuildTaskMgr::SendItemAdvertisement(uint32 itemId, uint32 owner, uint32 guildId, uint32 validIn)
{
Guild *guild = sGuildMgr->GetGuildById(guildId);
Player* player = sObjectMgr->GetPlayerByLowGUID(owner);
Player* leader = sObjectMgr->GetPlayerByLowGUID(guild->GetLeaderGUID());
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId);
if (!proto)
return false;
SQLTransaction trans = CharacterDatabase.BeginTransaction();
ostringstream body;
body << "Hello, " << player->GetName() << ",\n";
body << "\n";
body << "We are in a great need of " << proto->Name1 << ". If you could sell us ";
uint32 count = GetTaskValue(owner, guildId, "itemCount");
if (count > 1)
body << "at least " << count << " of them ";
else
body << "some ";
body << "we'd really appreciate that and pay a high price.\n";
body << "The task will expire in " << formatTime(validIn) << "\n";
body << "\n";
body << "Best Regards,\n";
body << guild->GetName() << "\n";
body << leader->GetName() << "\n";
ostringstream subject;
subject << "Guild Task: " << proto->Name1;
MailDraft(subject.str(), body.str()).SendMailTo(trans, MailReceiver(player), MailSender(leader));
CharacterDatabase.CommitTransaction(trans);
return true;
}
开发者ID:Cyph3r,项目名称:LordPsyanBots,代码行数:34,代码来源:GuildTaskMgr.cpp
示例4: data
void BlackMarketMgr::SendAuctionWon(BMAuctionEntry* auction, SQLTransaction& trans)
{
Player* bidder = sObjectAccessor->FindPlayer(MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER));
if (bidder)
{
WorldPacket data(SMSG_BLACK_MARKET_WON, 12);
data << uint32(1);
data << uint32(1);
data << uint32(auction->bmTemplate->itemEntry);
bidder->GetSession()->SendPacket(&data);
}
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(auction->bmTemplate->itemEntry);
if (!itemTemplate)
return;
Item* item = Item::CreateItem(auction->bmTemplate->itemEntry, auction->bmTemplate->itemCount);
if (!item)
return;
item->SaveToDB(trans);
MailDraft(auction->BuildAuctionMailSubject(BM_AUCTION_WON), auction->BuildAuctionMailBody(auction->bidder))
.AddItem(item)
.SendMailTo(trans, MailReceiver(bidder, auction->bidder), MailSender(auction), MAIL_CHECK_MASK_COPIED);
}
开发者ID:Exodius,项目名称:chuspi,代码行数:26,代码来源:BlackMarketMgr.cpp
示例5: GetBattlemasterEntry
void BattleGround::SendRewardMarkByMail(Player* plr, uint32 mark, uint32 count)
{
uint32 bmEntry = GetBattlemasterEntry();
if (!bmEntry)
return;
ItemPrototype const* markProto = ObjectMgr::GetItemPrototype(mark);
if (!markProto)
return;
if (Item* markItem = Item::CreateItem(mark, count, plr))
{
// save new item before send
markItem->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
int loc_idx = plr->GetSession()->GetSessionDbLocaleIndex();
// subject: item name
std::string subject = markProto->Name1;
sObjectMgr.GetItemLocaleStrings(markProto->ItemId, loc_idx, &subject);
// text
std::string textFormat = plr->GetSession()->GetMangosString(LANG_BG_MARK_BY_MAIL);
char textBuf[300];
snprintf(textBuf, 300, textFormat.c_str(), GetName(), GetName());
MailDraft(subject, textBuf)
.AddItem(markItem)
.SendMailTo(plr, MailSender(MAIL_CREATURE, bmEntry));
}
}
开发者ID:MonstermoshCOM,项目名称:server,代码行数:31,代码来源:BattleGround.cpp
示例6: ObjectGuid
void WorldSession::SendExternalMails()
{
//sLog.outString("EXTERNAL MAIL> Sending mails in queue...");
QueryResult *result = CharacterDatabase.Query("SELECT id,sender,receiver,subject,message,money,stationery FROM mail_external WHERE sent='0'");
if (!result)
{
//sLog.outString("EXTERNAL MAIL> No mails in queue...");
delete result;
return;
}
else
{
do
{
Field *fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
ObjectGuid senderGuid = ObjectGuid(fields[1].GetUInt64());
ObjectGuid receiverGuid = ObjectGuid(fields[2].GetUInt64());
std::string subject = fields[3].GetString();
std::string message = fields[4].GetString();
uint32 money = fields[5].GetUInt32();
if (Player* Receiver = sObjectMgr.GetPlayer(receiverGuid))
{
//sLog.outString("EXTERNAL MAIL> Send Mail %u to Player %u...", id, receiverGuid.GetCounter());
message = !message.empty() ? message : "Support Message";
MailDraft draft(subject, message);
QueryResult *result2 = CharacterDatabase.PQuery("SELECT item,count FROM mail_external_items WHERE mail_id='%u'", id);
if (result2)
{
do
{
Field *itemfields = result2->Fetch();
uint32 ItemID = itemfields[0].GetUInt32();
uint32 ItemCount = itemfields[1].GetUInt32();
Item* ToMailItem = ItemID ? Item::CreateItem(ItemID, ItemCount, Receiver) : NULL;
if (ToMailItem)
{
ToMailItem->SaveToDB();
draft.AddItem(ToMailItem);
}
}while(result2->NextRow());
}
delete result2;
if (money)
draft.SetMoney(money);
draft.SendMailTo(MailReceiver(Receiver), MailSender(MAIL_NORMAL, senderGuid.GetCounter(), MAIL_STATIONERY_DEFAULT), MAIL_CHECK_MASK_RETURNED);
CharacterDatabase.PExecute("UPDATE mail_external SET sent='1' WHERE id='%u'", id);
}
//else
//sLog.outString("EXTERNAL MAIL> Player %u not in game, skip Mail!", receiverGuid.GetCounter());
}while(result->NextRow());
}
delete result;
//sLog.outString("EXTERNAL MAIL> End Load External Mails...");
}
开发者ID:xXNembiXx,项目名称:mangos_335,代码行数:60,代码来源:Mail.cpp
示例7: receiverGuid
void WorldSession::SendExternalMails()
{
sLog->outCommand(0, "EXTERNAL MAIL> Sending mails in queue...");
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_GET_EXTERNAL_MAIL);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{
sLog->outCommand(0, "EXTERNAL MAIL> No mails in queue...");
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
MailDraft* mail = NULL;
do
{
Field *fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
uint32 receiver_guid = fields[1].GetUInt32();
ObjectGuid receiverGuid(HIGHGUID_PLAYER, receiver_guid);
std::string subject = fields[2].GetString();
std::string body = fields[3].GetString();
uint32 money = fields[4].GetUInt32();
uint32 itemId = fields[5].GetUInt32();
uint32 itemCount = fields[6].GetUInt32();
Player *receiver = ObjectAccessor::FindPlayer(receiverGuid);
mail = new MailDraft(subject, body);
if (money)
{
sLog->outCommand(0, "EXTERNAL MAIL> Adding money");
mail->AddMoney(money);
}
if (itemId)
{
sLog->outCommand(0, "EXTERNAL MAIL> Adding %u of item with id %u", itemCount, itemId);
Item* mailItem = Item::CreateItem(itemId, itemCount);
mailItem->SaveToDB(trans);
mail->AddItem(mailItem);
}
mail->SendMailTo(trans, receiver ? receiver : MailReceiver(receiver_guid), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
delete mail;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXTERNAL_MAIL);
stmt->setUInt32(0, id);
trans->Append(stmt);
sLog->outCommand(0, "EXTERNAL MAIL> Mail sent");
}
while (result->NextRow());
CharacterDatabase.CommitTransaction(trans);
sLog->outCommand(0, "EXTERNAL MAIL> All Mails Sent...");
}
开发者ID:Exitare,项目名称:Wotlk-Core,代码行数:60,代码来源:Mail.cpp
示例8: MAKE_NEW_GUID
void BlackMarketMgr::SendAuctionWon(BMAuctionEntry* auction, SQLTransaction& trans)
{
uint64 bidderGUID = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
Player* bidder = sObjectAccessor->FindPlayer(bidderGUID);
if (bidder)
{
WorldPacket data(SMSG_BLACKMARKET_WON, 12);
data << uint32(1);
data << uint32(1);
data << uint32(auction->bm_template->itemEntry);
bidder->GetSession()->SendPacket(&data);
}
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(auction->bm_template->itemEntry);
if (!itemTemplate)
return;
Item* pItem = Item::CreateItem(auction->bm_template->itemEntry, auction->bm_template->itemCount, bidder);
// Create new item in the database
//SQLTransaction trans2 = CharacterDatabase.BeginTransaction();
pItem->SetOwnerGUID(bidderGUID);
pItem->SaveToDB(trans);
//CharacterDatabase.CommitTransaction(trans2);
MailDraft(auction->BuildAuctionMailSubject(BM_AUCTION_WON), auction->BuildAuctionMailBody(auction->bidder))
.AddItem(pItem)
.SendMailTo(trans, MailReceiver(bidder, auction->bidder), MailSender(auction), MAIL_CHECK_MASK_COPIED);
}
开发者ID:Cailiaock,项目名称:5.4.7-Wow-source,代码行数:30,代码来源:BlackMarketMgr.cpp
示例9: formatTime
bool GuildTaskMgr::SendKillAdvertisement(uint32 creatureId, uint32 owner, uint32 guildId, uint32 validIn)
{
Guild *guild = sGuildMgr->GetGuildById(guildId);
Player* player = sObjectMgr->GetPlayerByLowGUID(owner);
Player* leader = sObjectMgr->GetPlayerByLowGUID(guild->GetLeaderGUID());
CreatureTemplate const* proto = sObjectMgr->GetCreatureTemplate(creatureId);
if (!proto)
return false;
SQLTransaction trans = CharacterDatabase.BeginTransaction();
ostringstream body;
body << "Hello, " << player->GetName() << ",\n";
body << "\n";
body << "As you probably know " << proto->Name << " is wanted dead for the crimes it did against our guild. If you should kill it ";
body << "we'd really appreciate that.\n";
body << "The task will expire in " << formatTime(validIn) << "\n";
body << "\n";
body << "Best Regards,\n";
body << guild->GetName() << "\n";
body << leader->GetName() << "\n";
ostringstream subject;
subject << "Guild Task: " << proto->Name;
MailDraft(subject.str(), body.str()).SendMailTo(trans, MailReceiver(player), MailSender(leader));
CharacterDatabase.CommitTransaction(trans);
return true;
}
开发者ID:Cyph3r,项目名称:LordPsyanBots,代码行数:29,代码来源:GuildTaskMgr.cpp
示例10: deleteIncludedItems
void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid )
{
Player *receiver = sObjectMgr.GetPlayer(MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
uint32 rc_account = 0;
if(!receiver)
rc_account = sObjectMgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
if(!receiver && !rc_account) // sender not exist
{
deleteIncludedItems(true);
return;
}
// prepare mail and send in other case
bool needItemDelay = false;
if(!m_items.empty())
{
// if item send to character at another account, then apply item delivery delay
needItemDelay = sender_acc != rc_account;
// set owner to new receiver (to prevent delete item with sender char deleting)
CharacterDatabase.BeginTransaction();
for(MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{
Item* item = mailItemIter->second;
item->SaveToDB(); // item not in inventory and can be save standalone
// owner in data will set at mail receive and item extracting
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", receiver_guid, item->GetGUIDLow());
}
CharacterDatabase.CommitTransaction();
}
// If theres is an item, there is a one hour delivery delay.
uint32 deliver_delay = needItemDelay ? sWorld.getConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
// will delete item or place to receiver mail list
if (sender_guid == auctionbot.GetAHBplayerGUID())
{
SendMailTo(MailReceiver(receiver,receiver_guid), MailSender(MAIL_CREATURE, sender_guid), MAIL_CHECK_MASK_RETURNED, deliver_delay);
}
else
{
SendMailTo(MailReceiver(receiver,receiver_guid), MailSender(MAIL_NORMAL, sender_guid), MAIL_CHECK_MASK_RETURNED, deliver_delay);
}
}
开发者ID:DJoRiK,项目名称:mangos,代码行数:47,代码来源:Mail.cpp
示例11: MailDraft
void WorldSession::SendExternalMails()
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_GET_EXTERNAL_MAIL);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
MailDraft* mail = NULL;
do
{
Field *fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
uint32 receiver_guid = fields[1].GetUInt32();
std::string subject = fields[2].GetString();
std::string body = fields[3].GetString();
uint32 money = fields[4].GetUInt32();
uint32 itemId = fields[5].GetUInt32();
uint32 itemCount = fields[6].GetUInt32();
Player *receiver = sObjectMgr->GetPlayerByLowGUID(receiver_guid);
mail = new MailDraft(subject, body);
if (money)
{
mail->AddMoney(money);
}
if (itemId)
{
Item* mailItem = Item::CreateItem(itemId, itemCount);
mailItem->SaveToDB(trans);
mail->AddItem(mailItem);
}
mail->SendMailTo(trans, receiver ? receiver : MailReceiver(receiver_guid), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_RETURNED);
delete mail;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXTERNAL_MAIL);
stmt->setUInt32(0, id);
trans->Append(stmt);
}
while (result->NextRow());
CharacterDatabase.CommitTransaction(trans);
}
开发者ID:bromacia,项目名称:TrinityCore-3.3.5a,代码行数:53,代码来源:Mail.cpp
示例12: fixgutschein
void fixgutschein(Player* player, uint32 belohnung, uint32 anzahl, std::string grund ){
CharacterDatabase.PExecute("INSERT INTO item_codes (code,belohnung,anzahl,benutzt,name,benutztbar) Values ('%s','%u','%u','%u','%s','%u')", grund, belohnung, anzahl, 1, player->GetName(),1);
Item* item = Item::CreateItem(belohnung, anzahl);
player->GetSession()->SendNotification("Dein Code wurde generiert und die Belohnung zugesendet!");
SQLTransaction trans = CharacterDatabase.BeginTransaction();
item->SaveToDB(trans);
MailDraft("Dein Gutscheincode", "Dein Code wurde erfolgreich eingeloest. Wir wuenschen dir weiterhin viel Spass auf MMOwning. Dein MMOwning-Team").AddItem(item)
.SendMailTo(trans, MailReceiver(player, player->GetGUID()), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM));
CharacterDatabase.CommitTransaction(trans);
DBeintrag(player->GetSession()->GetPlayer(), "fixgutschein");
return;
}
开发者ID:Exitare,项目名称:Testrealm-Core,代码行数:13,代码来源:ex_firstnpc.cpp
示例13: MailDraft
void GameEventMgr::SendEventMails(int16 event_id)
{
int32 internal_event_id = mGameEvent.size() + event_id - 1;
MailList const& mails = mGameEventMails[internal_event_id];
for (MailList::const_iterator itr = mails.begin(); itr != mails.end(); ++itr)
{
if (itr->questId)
{
// need special query
std::ostringstream ss;
ss << "SELECT characters.guid FROM characters, character_queststatus "
"WHERE (1 << (characters.race - 1)) & "
<< itr->raceMask
<< " AND characters.deleteDate IS NULL AND character_queststatus.guid = characters.guid AND character_queststatus.quest = "
<< itr->questId
<< " AND character_queststatus.rewarded <> 0";
sMassMailMgr.AddMassMailTask(new MailDraft(itr->mailTemplateId), MailSender(MAIL_CREATURE, itr->senderEntry), ss.str().c_str());
}
else
sMassMailMgr.AddMassMailTask(new MailDraft(itr->mailTemplateId), MailSender(MAIL_CREATURE, itr->senderEntry), itr->raceMask);
}
}
开发者ID:tedvals,项目名称:portalclassic,代码行数:24,代码来源:GameEventMgr.cpp
示例14: MAKE_NEW_GUID
void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid,
uint32 receiver_guid, SQLTransaction& trans) {
Player *receiver = sObjectMgr->GetPlayer(
MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
uint32 rc_account = 0;
if (!receiver)
rc_account = sObjectMgr->GetPlayerAccountIdByGUID(
MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
if (!receiver && !rc_account) // sender not exist
{
deleteIncludedItems(trans, true);
return;
}
// prepare mail and send in other case
bool needItemDelay = false;
if (!m_items.empty()) {
// if item send to character at another account, then apply item delivery delay
needItemDelay = sender_acc != rc_account;
// set owner to new receiver (to prevent delete item with sender char deleting)
for (MailItemMap::iterator mailItemIter = m_items.begin();
mailItemIter != m_items.end(); ++mailItemIter) {
Item* item = mailItemIter->second;
item->SaveToDB(trans); // item not in inventory and can be save standalone
// owner in data will set at mail receive and item extracting
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(
CHAR_SET_ITEM_OWNER);
stmt->setUInt32(0, receiver_guid);
stmt->setUInt32(1, item->GetGUIDLow());
trans->Append(stmt);
}
}
// If theres is an item, there is a one hour delivery delay.
uint32 deliver_delay =
needItemDelay ?
sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
// will delete item or place to receiver mail list
SendMailTo(trans, MailReceiver(receiver, receiver_guid),
MailSender(MAIL_NORMAL, sender_guid), MAIL_CHECK_MASK_RETURNED,
deliver_delay);
}
开发者ID:BlueSellafield,项目名称:ArkCORE,代码行数:47,代码来源:Mail.cpp
示例15: OnCheck
bool OnCheck(Player* player, Unit* target)
{
if (!player)
return false;
// this is a duplicated criteria check but we need it since we are not
// really doing any check here but just use this as a hook to send out
// the achievement related mails.
if (!player->GetQuestRewardStatus(_questEntry))
return false;
// if we are here we need to create the mail for the stupid brew of the year club
uint32 brew_of_the_month_beers[12] = {37496, 37497, 37498, 37499, 37488, 37489, 37490, 37491, 37492, 37493, 37494, 37495}; // sep-aug
uint32 delay = 0;
for (uint8 iter = 0; iter < 12; ++iter)
{
Item* item = brew_of_the_month_beers[iter] ? Item::CreateItem(brew_of_the_month_beers[iter], 1, player) : NULL;
// subject and text
std::string subject = "Bräu des Monats!";
std::string text = "Deine monatliche Bier-Lieferung befindet sich im Anhang.$B$BProst!";
MailDraft draft(subject, text);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (item)
{
// save new item before send
item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
// item
draft.AddItem(item);
}
draft.SendMailTo(trans, player, MailSender(MAIL_CREATURE, 28329), MAIL_CHECK_MASK_HAS_BODY, delay);
CharacterDatabase.CommitTransaction(trans);
// TODO calculate correct send times
delay += 30*86400;
}
sLog->outInfo(LOG_FILTER_TSCR, "Player %s achieved Brew of the Month Club and has 12 mails added with beer over the next 12 month.", player->GetName());
return true;
}
开发者ID:Marchmalo,项目名称:TrinityElron103,代码行数:43,代码来源:achievement_scripts.cpp
示例16: Belohnung
void Belohnung(Player* player, std::string codes){
PreparedStatement* selantwort = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ANTWORTEN_NACH_ANTWORT);
selantwort->setString(0, codes);
PreparedQueryResult ergebnis = CharacterDatabase.Query(selantwort);
if (!ergebnis){
player->GetSession()->SendNotification("Deine Antwort ist nicht korrekt!");
return;
}
if (ergebnis){
Field* felder = ergebnis->Fetch();
uint32 id = felder[0].GetUInt32();
uint32 belohnung = felder[1].GetUInt32();
uint32 anzahl = felder[2].GetUInt32();
PreparedStatement* check = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BEANTWORTET);
check->setInt32(0, player->GetSession()->GetAccountId());
check->setInt32(1, id);
PreparedQueryResult result = CharacterDatabase.Query(check);
if (result){
player->GetSession()->SendNotification("Du hast die Frage schon beantwortet. Dies ist nur einmal pro Account moeglich!");
return;
}
PreparedStatement* insertfrage = CharacterDatabase.GetPreparedStatement(CHAR_INS_BEANTWORTET);
insertfrage->setInt32(0, player->GetSession()->GetAccountId());
insertfrage->setInt32(1, id);
CharacterDatabase.Execute(insertfrage);
Item* item = Item::CreateItem(belohnung, anzahl);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
item->SaveToDB(trans);
MailDraft("Raetselbelohnung", "Du hast ein Raetsel geloest und hier ist deine Belohnung.").AddItem(item)
.SendMailTo(trans, MailReceiver(player, player->GetGUID()), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM));
CharacterDatabase.CommitTransaction(trans);
player->GetSession()->SendNotification("Deine Antwort war korrekt. Deine Belohnung wurde zugesandt.");
return;
}
}
开发者ID:Exitare,项目名称:Testrealm-Core,代码行数:43,代码来源:ex_codenpc.cpp
示例17: gutscheinzusammenstellen
void gutscheinzusammenstellen(Player* player, uint32 belohnung, uint32 anzahl, std::string str){
CharacterDatabase.PExecute("INSERT INTO `item_codes` (code,belohnung,anzahl,benutzt,benutztbar) Values ('%s','%u','%u','%u','%u')", str, belohnung, anzahl, 0,1);
std::ostringstream ss;
std::ostringstream tt;
ss << "Dein Code lautet: " << str << " . Wir wuenschen dir weiterhin viel Spass auf MMOwning. Dein MMOwning-Team";
player->GetSession()->SendNotification("Dein Code wurde generiert und dir zugesendet.");
tt << "Gutscheincode: " << str;
ChatHandler(player->GetSession()).PSendSysMessage(tt.str().c_str(),
player->GetName());
SQLTransaction trans = CharacterDatabase.BeginTransaction();
MailDraft("Dein Gutscheincode", ss.str().c_str())
.SendMailTo(trans, MailReceiver(player, player->GetGUID()), MailSender(MAIL_NORMAL, 0, MAIL_STATIONERY_GM));
CharacterDatabase.CommitTransaction(trans);
DBeintrag(player->GetSession()->GetPlayer(), "Gutschein zum verschenken");
return;
}
开发者ID:Exitare,项目名称:Testrealm-Core,代码行数:21,代码来源:ex_firstnpc.cpp
示例18: deleteIncludedItems
void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, SQLTransaction& trans)
{
Player* receiver = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
uint32 rc_account = 0;
if (!receiver)
rc_account = sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
if (!receiver && !rc_account) // sender not exist
{
deleteIncludedItems(trans, true);
return;
}
if (!m_items.empty())
{
// if item send to character at another account, then apply item delivery delay
//needItemDelay = sender_acc != rc_account;
// set owner to new receiver (to prevent delete item with sender char deleting)
for (MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{
Item* item = mailItemIter->second;
item->SaveToDB(trans); // item not in inventory and can be save standalone
// owner in data will set at mail receive and item extracting
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
stmt->setUInt32(0, receiver_guid);
stmt->setUInt32(1, item->GetGUIDLow());
trans->Append(stmt);
}
}
// xinef: WowWiki: "Return mail arrives immediately."
// will delete item or place to receiver mail list
SendMailTo(trans, MailReceiver(receiver, receiver_guid), MailSender(MAIL_NORMAL, sender_guid), MAIL_CHECK_MASK_RETURNED, 0);
}
开发者ID:boom8866,项目名称:azerothcore-wotlk,代码行数:37,代码来源:Mail.cpp
示例19: MAKE_NEW_GUID
//called when player takes item attached in mail
void WorldSession::HandleMailTakeItem(WorldPacket & recv_data)
{
uint64 mailbox;
uint32 mailId;
uint32 itemId;
recv_data >> mailbox;
recv_data >> mailId;
recv_data >> itemId; // item guid low
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
return;
Player* pl = _player;
Mail* m = pl->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return;
}
// prevent cheating with skip client money check
if (!pl->HasEnoughMoney(uint32(m->COD)))
{
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
Item *it = pl->GetMItem(itemId);
ItemPosCountVec dest;
uint8 msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, it, false);
if (msg == EQUIP_ERR_OK)
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
m->RemoveItem(itemId);
m->removedItems.push_back(itemId);
if (m->COD > 0) //if there is COD, take COD money from player and send them to sender by mail
{
uint64 sender_guid = MAKE_NEW_GUID(m->sender, 0, HIGHGUID_PLAYER);
Player *receive = sObjectMgr->GetPlayer(sender_guid);
uint32 sender_accId = 0;
if (GetSecurity() > SEC_PLAYER && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
{
std::string sender_name;
if (receive)
{
sender_accId = receive->GetSession()->GetAccountId();
sender_name = receive->GetName();
}
else
{
// can be calculated early
sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(sender_guid);
if (!sObjectMgr->GetPlayerNameByGUID(sender_guid, sender_name))
sender_name = sObjectMgr->GetStarGateStringForDBCLocale(LANG_UNKNOWN);
}
sLog->outCommand(GetAccountId(), "GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: "UI64FMTD" to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId);
}
else if (!receive)
sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(sender_guid);
// check player existence
if (receive || sender_accId)
{
MailDraft(m->subject, "")
.AddMoney(m->COD)
.SendMailTo(trans, MailReceiver(receive, m->sender), MailSender(MAIL_NORMAL, m->receiver), MAIL_CHECK_MASK_COD_PAYMENT);
}
pl->ModifyMoney(-int32(m->COD));
}
m->COD = 0;
m->state = MAIL_STATE_CHANGED;
pl->m_mailsUpdated = true;
pl->RemoveMItem(it->GetGUIDLow());
uint32 count = it->GetCount(); // save counts before store and possible merge with deleting
pl->MoveItemToInventory(dest, it, true);
pl->SaveInventoryAndGoldToDB(trans);
pl->_SaveMail(trans);
CharacterDatabase.CommitTransaction(trans);
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_OK, 0, itemId, count);
}
else
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg);
}
开发者ID:ProjectStarGate,项目名称:StarGateEmu-Projekt,代码行数:95,代码来源:MailHandler.cpp
示例20: GetPlayer
//.........这里部分代码省略.........
if (!item)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if (!item->CanBeTraded(true))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
}
if (item->IsBoundAccountWide() && item->IsSoulBound() && pl->GetSession()->GetAccountId() != rc_account)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS);
return;
}
if (item->GetProto()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
}
if (COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
return;
}
if (item->IsBag() && !((Bag*)item)->IsEmpty())
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS);
return;
}
items[i] = item;
}
pl->SendMailResult(0, MAIL_SEND, MAIL_OK);
pl->ModifyMoney(-int32(reqmoney));
pl->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost);
bool needItemDelay = false;
MailDraft draft(subject, body);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (items_count > 0 || money > 0)
{
if (items_count > 0)
{
for (uint8 i = 0; i < items_count; ++i)
{
Item* item = items[i];
if (GetSecurity() > SEC_PLAYER && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
{
sLog->outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account);
}
item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable
pl->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true);
item->DeleteFromInventoryDB(trans); // deletes item from character's inventory
i
|
请发表评论