bool OnGossipHello(Player* pPlayer, Creature* /*pCreature*/) { if( pPlayer->IsActiveQuest( QUEST_A_MEETING_WITH_THE_MAGISTER ) && pPlayer->GetQuestStatus( QUEST_A_MEETING_WITH_THE_MAGISTER ) != QUEST_STATUS_COMPLETE ) { ItemPosCountVec dest; uint32 count = 1, no_space_count = 0; uint8 msg = pPlayer->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, ITEM_QUEST, count, &no_space_count ); if( msg == EQUIP_ERR_ITEM_NOT_FOUND ) { sLog->outErrorDb( "[src/server/scripts/Northrend/dalaran.cpp] Item (Entry %u) not exist in `item_template`.", ITEM_QUEST ); return false; } if( msg != EQUIP_ERR_OK ) // convert to possible store amount count -= no_space_count; if( count != 0 && !dest.empty( ) ) // can add some if( Item* item = pPlayer->StoreNewItem( dest, ITEM_QUEST, true, 0 ) ) pPlayer->SendNewItem( item, count, true, false ); } if( pPlayer->GetQuestStatus( QUEST_AN_AUDIENCE_WITH_THE_ARCANIST ) == QUEST_STATUS_COMPLETE ) { if( pPlayer->HasAura( SPELL_SILVER_COVENANT_DISGUISE_F ) ) pPlayer->RemoveAurasDueToSpell( SPELL_SILVER_COVENANT_DISGUISE_F ); if( pPlayer->HasAura( SPELL_SILVER_COVENANT_DISGUISE_M ) ) pPlayer->RemoveAurasDueToSpell( SPELL_SILVER_COVENANT_DISGUISE_M ); } return false; }
void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_AUTOBANK_ITEM"); uint8 srcbag, srcslot; recvPacket >> srcbag >> srcslot; sLog->outDebug(LOG_FILTER_NETWORKIO, "STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot); Item* pItem = _player->GetItemByPos(srcbag, srcslot); if (!pItem) return; ItemPosCountVec dest; InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, pItem, false); if (msg != EQUIP_ERR_OK) { _player->SendEquipError(msg, pItem, NULL); return; } if (dest.size() == 1 && dest[0].pos == pItem->GetPos()) { _player->SendEquipError(EQUIP_ERR_NONE, pItem, NULL); return; } _player->RemoveItem(srcbag, srcslot, true); _player->ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount()); _player->BankItem(dest, pItem, true); }
void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) { DEBUG_LOG("WORLD: CMSG_AUTOBANK_ITEM"); uint8 srcbag, srcslot; recvPacket >> srcbag >> srcslot; DEBUG_LOG("STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot); Item *pItem = _player->GetItemByPos( srcbag, srcslot ); if( !pItem ) return; ItemPosCountVec dest; uint8 msg = _player->CanBankItem( NULL_BAG, NULL_SLOT, dest, pItem, false ); if( msg != EQUIP_ERR_OK ) { _player->SendEquipError( msg, pItem, NULL ); return; } // no-op: placed in same slot if(dest.size() == 1 && dest[0].pos == pItem->GetPos()) { // just remove gray item state _player->SendEquipError( EQUIP_ERR_NONE, pItem, NULL ); return; } _player->RemoveItem(srcbag, srcslot, true); _player->BankItem( dest, pItem, true ); }
void BattleGround::RewardMark(Player *plr,uint32 count) { // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens if(plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) return; BattleGroundMarks mark; bool IsSpell; switch(GetTypeID()) { case BATTLEGROUND_AV: IsSpell = true; if(count == ITEM_WINNER_COUNT) mark = SPELL_AV_MARK_WINNER; else mark = SPELL_AV_MARK_LOSER; break; case BATTLEGROUND_WS: IsSpell = true; if(count == ITEM_WINNER_COUNT) mark = SPELL_WS_MARK_WINNER; else mark = SPELL_WS_MARK_LOSER; break; case BATTLEGROUND_AB: IsSpell = true; if(count == ITEM_WINNER_COUNT) mark = SPELL_AB_MARK_WINNER; else mark = SPELL_AB_MARK_LOSER; break;/* case BATTLEGROUND_EY: IsSpell = false; mark = ITEM_EY_MARK_OF_HONOR; break;*/ default: return; } if(IsSpell) plr->CastSpell(plr, mark, true); else if ( objmgr.GetItemPrototype( mark ) ) { ItemPosCountVec dest; uint32 no_space_count = 0; uint8 msg = plr->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, mark, count, &no_space_count ); if( msg != EQUIP_ERR_OK ) // convert to possible store amount count -= no_space_count; if( count != 0 && !dest.empty()) // can add some if(Item* item = plr->StoreNewItem( dest, mark, true, 0)) plr->SendNewItem(item,count,false,true); if(no_space_count > 0) SendRewardMarkByMail(plr,mark,no_space_count); } }
void AddItemChoixS(Player *player, uint32 item_id, int choix) { uint32 noSpaceForCount = 0; ItemPosCountVec dest; InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item_id, 1, &noSpaceForCount); if (msg != EQUIP_ERR_OK) if (dest.empty()) { ChatHandler(player->GetSession()).PSendSysMessage("Vous n'avez plus de place."); return; } if (Item* item = player->StoreNewItem(dest, item_id, true, ChoixS(item_id, choix))) player->SendNewItem(item, 1, true, false); return; }
void WorldSession::HandleAutoStoreBagItemOpcode(WorldPackets::Item::AutoStoreBagItem& packet) { if (!packet.Inv.Items.empty()) { TC_LOG_ERROR("network", "HandleAutoStoreBagItemOpcode - Invalid itemCount (" SZFMTD ")", packet.Inv.Items.size()); return; } TC_LOG_DEBUG("network", "HandleAutoStoreBagItemOpcode: receive ContainerSlotA: %u, SlotA: %u, ContainerSlotB: %u", packet.ContainerSlotA, packet.SlotA, packet.ContainerSlotB); Item* item = _player->GetItemByPos(packet.ContainerSlotA, packet.SlotA); if (!item) return; if (!_player->IsValidPos(packet.ContainerSlotB, NULL_SLOT, false)) // can be autostore pos { _player->SendEquipError(EQUIP_ERR_WRONG_SLOT); return; } uint16 src = item->GetPos(); // check unequip potability for equipped items and bank bags if (_player->IsEquipmentPos(src) || _player->IsBagPos(src)) { InventoryResult msg = _player->CanUnequipItem(src, !_player->IsBagPos(src)); if (msg != EQUIP_ERR_OK) { _player->SendEquipError(msg, item); return; } } ItemPosCountVec dest; InventoryResult msg = _player->CanStoreItem(packet.ContainerSlotB, NULL_SLOT, dest, item, false); if (msg != EQUIP_ERR_OK) { _player->SendEquipError(msg, item); return; } // no-op: placed in same slot if (dest.size() == 1 && dest[0].pos == src) { // just remove grey item state _player->SendEquipError(EQUIP_ERR_INTERNAL_BAG_ERROR, item); return; } _player->RemoveItem(packet.ContainerSlotA, packet.SlotA, true); _player->StoreItem(dest, item, true); }
void WorldSession::HandleAutoStoreBagItemOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,1+1+1); //sLog.outDebug("WORLD: CMSG_AUTOSTORE_BAG_ITEM"); uint8 srcbag, srcslot, dstbag; recv_data >> srcbag >> srcslot >> dstbag; //sLog.outDebug("STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u", srcbag, srcslot, dstbag); Item *pItem = _player->GetItemByPos( srcbag, srcslot ); if( !pItem ) return; if(!_player->IsValidPos(dstbag,NULL_SLOT)) { _player->SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL ); return; } uint16 src = pItem->GetPos(); // check unequip potability for equipped items and bank bags if(_player->IsEquipmentPos ( src ) || _player->IsBagPos ( src )) { uint8 msg = _player->CanUnequipItem( src, !_player->IsBagPos ( src )); if(msg != EQUIP_ERR_OK) { _player->SendEquipError( msg, pItem, NULL ); return; } } ItemPosCountVec dest; uint8 msg = _player->CanStoreItem( dstbag, NULL_SLOT, dest, pItem, false ); if( msg != EQUIP_ERR_OK ) { _player->SendEquipError( msg, pItem, NULL ); return; } // no-op: placed in same slot if(dest.size()==1 && dest[0].pos==src) { // just remove grey item state _player->SendEquipError( EQUIP_ERR_NONE, pItem, NULL ); return; } _player->RemoveItem(srcbag, srcslot, true ); _player->StoreItem( dest, pItem, true ); }
void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket& recvData) { //TC_LOG_DEBUG("network", "WORLD: CMSG_AUTOSTORE_BAG_ITEM"); uint8 srcbag, srcslot, dstbag; recvData >> srcbag >> srcslot >> dstbag; //TC_LOG_DEBUG("STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u", srcbag, srcslot, dstbag); Item* pItem = _player->GetItemByPos(srcbag, srcslot); if (!pItem) return; if (!_player->IsValidPos(dstbag, NULL_SLOT, false)) // can be autostore pos { _player->SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, nullptr, nullptr); return; } uint16 src = pItem->GetPos(); // check unequip potability for equipped items and bank bags if (_player->IsEquipmentPos (src) || _player->IsBagPos (src)) { InventoryResult msg = _player->CanUnequipItem(src, !_player->IsBagPos (src)); if (msg != EQUIP_ERR_OK) { _player->SendEquipError(msg, pItem, nullptr); return; } } ItemPosCountVec dest; InventoryResult msg = _player->CanStoreItem(dstbag, NULL_SLOT, dest, pItem, false); if (msg != EQUIP_ERR_OK) { _player->SendEquipError(msg, pItem, nullptr); return; } // no-op: placed in same slot if (dest.size() == 1 && dest[0].pos == src) { // just remove grey item state _player->SendEquipError(EQUIP_ERR_NONE, pItem, nullptr); return; } _player->RemoveItem(srcbag, srcslot, true); _player->StoreItem(dest, pItem, true); }
void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) { DEBUG_LOG("WORLD: CMSG_AUTOBANK_ITEM"); uint8 srcbag, srcslot; recvPacket >> srcbag >> srcslot; DEBUG_LOG("STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot); Item *pItem = _player->GetItemByPos( srcbag, srcslot ); if( !pItem ) return; // WPE dupe protection if(pItem->IsBag()) if(!((Bag *)pItem)->IsEmpty()) { // GM announce sWorld.SendGMWorldText(SECURITY_MODERATOR, LANG_ANTIWPE_NOTIFY, GetPlayerName(), pItem->GetProto()->ItemId); sLog.outInterest("WPE PROTECTION: Hrac %s duplikuje pomocou itemu %u", GetPlayerName(), pItem->GetProto()->ItemId); // Permanent Ban sWorld.BanAccount(BAN_CHARACTER, GetPlayerName(),0 ,"WPE Duplication Item","Casso's WPE Protection"); } ItemPosCountVec dest; uint8 msg = _player->CanBankItem( NULL_BAG, NULL_SLOT, dest, pItem, false ); if( msg != EQUIP_ERR_OK ) { _player->SendEquipError( msg, pItem, NULL ); return; } // no-op: placed in same slot if(dest.size() == 1 && dest[0].pos == pItem->GetPos()) { // just remove gray item state _player->SendEquipError( EQUIP_ERR_NONE, pItem, NULL ); return; } _player->RemoveItem(srcbag, srcslot, true); _player->BankItem( dest, pItem, true ); }
void BattleGround::RewardItem(Player* plr, uint32 item_id, uint32 count) { ItemPosCountVec dest; uint32 no_space_count = 0; uint8 msg = plr->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item_id, count, &no_space_count); if (msg == EQUIP_ERR_ITEM_NOT_FOUND) { sLog.outErrorDb("Battleground reward item (Entry %u) not exist in `item_template`.", item_id); return; } if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= no_space_count; if (count != 0 && !dest.empty()) // can add some if (Item* item = plr->StoreNewItem(dest, item_id, true, 0)) plr->SendNewItem(item, count, true, false); if (no_space_count > 0) SendRewardMarkByMail(plr, item_id, no_space_count); }
void BattlefieldWG::RewardMarkOfHonor(Player* player, uint32 count) { // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens if (count == 0) return; ItemPosCountVec dest; uint32 no_space_count = 0; uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, WG_MARK_OF_HONOR, count, &no_space_count); if (msg == EQUIP_ERR_ITEM_NOT_FOUND) { return; } if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= no_space_count; if (count != 0 && !dest.empty()) // can add some if (Item * item = player->StoreNewItem(dest, WG_MARK_OF_HONOR, true, 0)) player->SendNewItem(item, count, true, false); }
void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) { TC_LOG_DEBUG("network", "WORLD: CMSG_AUTOBANK_ITEM"); uint8 srcbag, srcslot; recvPacket >> srcbag >> srcslot; TC_LOG_DEBUG("network", "STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot); if (!CanUseBank()) { TC_LOG_DEBUG("network", "WORLD: HandleAutoBankItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str()); return; } Item* pItem = _player->GetItemByPos(srcbag, srcslot); if (!pItem) return; ItemPosCountVec dest; InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, pItem, false); if (msg != EQUIP_ERR_OK) { _player->SendEquipError(msg, pItem, nullptr); return; } if (dest.size() == 1 && dest[0].pos == pItem->GetPos()) { _player->SendEquipError(EQUIP_ERR_NONE, pItem, nullptr); return; } _player->RemoveItem(srcbag, srcslot, true); _player->ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount()); _player->BankItem(dest, pItem, true); }
static bool HandleBoutiqueItemCommand(ChatHandler *handler, const char *args) { uint32 achatId = (uint32)atol(args); if (!achatId) { handler->PSendSysMessage(11007, handler->GetSession()->GetPlayerName().c_str()); return false; } const char* reqcount = "SELECT nom, itemId, recup, quantite FROM boutique_achat WHERE accountId = '%u' AND id='%u'"; QueryResult resultcount = LoginDatabase.PQuery(reqcount, handler->GetSession()->GetAccountId(), achatId); if (!resultcount) { //Cet achat n'existe pas, ne vous est pas attribue ou n'est pas disponible sur ce serveur. handler->PSendSysMessage(11008); return true; } Field* fieldscount = resultcount->Fetch(); //Vous avez déjà attribué cet achat à un de vos personnages if (fieldscount[2].GetInt32()!=0) { const char* reqperso = "SELECT count(*), name FROM characters WHERE guid='%u'"; QueryResult resultperso = CharacterDatabase.PQuery(reqperso, fieldscount[2].GetInt32()); Field* fieldperso = resultperso->Fetch(); handler->PSendSysMessage(11014, fieldperso[1].GetCString()); } uint32 itemId = fieldscount[1].GetInt32(); const char* qmask = "SELECT 1 FROM boutique_produit WHERE realmMask & '%u' != 0 and itemId = '%u'"; QueryResult reqmask = LoginDatabase.PQuery(qmask, (1<<(realmID-1)), itemId); if (!reqmask) { //Ce produit ou service n'est pas disponible pour ce royaume. handler->PSendSysMessage(11018); return true; } ItemTemplate const *tmp = sObjectMgr->GetItemTemplate(itemId); if (!tmp) { handler->PSendSysMessage(11011); //Cet objet n'existe pas. Veuillez contacter un MJ et lui d�©crire le probl�¨me return false; } //Adding items uint32 noSpaceForCount = 0; Player* plTarget = handler->GetSession()->GetPlayer(); Player* pl = plTarget; uint32 count = fieldscount[3].GetInt32(); // check space and find places ItemPosCountVec dest; uint8 msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= noSpaceForCount; if (count == 0 || dest.empty()) // can't add any { handler->PSendSysMessage(11015); handler->SetSentErrorMessage(true); return false; } Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) { if (Item* item1 = pl->GetItemByPos(itr->pos)) { item1->SetBinding(true); } } if (count > 0 && item) { plTarget->SendNewItem(item,count,true,false); const char* requpdate = "UPDATE boutique_achat SET realmID = '%u', recup='%u' WHERE id='%u'"; LoginDatabase.PExecute(requpdate, realmID, (uint32)handler->GetSession()->GetPlayer()->GetGUIDLow(), achatId); handler->PSendSysMessage(11013, fieldscount[0].GetCString()); } if (noSpaceForCount > 0) handler->PSendSysMessage(11015); plTarget->SaveToDB(); return true; }
bool ChatHandler::HandleAddItemToAllCommand(char* args) { if (!*args) return false; uint32 itemId = 0; // Vyextrahovanie mena itemu if (args[0] == '[') // [name] manual form { char* citemName = citemName = strtok((char*)args, "]"); if (citemName && citemName[0]) { std::string itemName = citemName + 1; WorldDatabase.escape_string(itemName); QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str()); if (!result) { PSendSysMessage(LANG_COMMAND_COULDNOTFIND, citemName + 1); SetSentErrorMessage(true); return false; } itemId = result->Fetch()->GetUInt16(); delete result; } else return false; } else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r { char* cId = ExtractKeyFromLink(&args, "Hitem"); if (!cId) return false; itemId = atol(cId); } // Ziskanie poctu itemov (nepovinny parameter, defaultne 1) char* ccount = strtok(NULL, " "); int32 countproto = 1; if (ccount) countproto = strtol(ccount, NULL, 10); if (countproto == 0) countproto = 1; //Odrstranenie itemov sa nepovoluje if (countproto < 0) { // TODO bodol by aj vypis return false; } // Ziskanie typu itemu ItemPrototype const *pProto = sObjectMgr.GetItemPrototype(itemId); if (!pProto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); SetSentErrorMessage(true); return false; } Player* pl = m_session->GetPlayer(); // Prechod vsetkymi hracmi servra HashMapHolder<Player>::MapType& m = ObjectAccessor::Instance().GetPlayers(); for (HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr) { int32 count = countproto; Player* plTarget = itr->second; //Adding items uint32 noSpaceForCount = 0; // check space and find places ItemPosCountVec dest; uint8 msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= noSpaceForCount; if (count == 0 || dest.empty()) // can't add any { PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); SetSentErrorMessage(true); continue; } Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); if (count > 0 && item) { pl->SendNewItem(item, count, false, true); if (pl != plTarget) plTarget->SendNewItem(item, count, true, false); } if (noSpaceForCount > 0) PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); } return true; }
static bool HandleModAddItemCommand(ChatHandler* handler, const char* args) { if (!*args) return false; uint32 itemId = 0; int32 count = 1; char* cId = handler->extractKeyFromLink((char*)args, "Hitem"); if (!cId) return false; itemId = atol(cId); Player* pl = handler->GetSession()->GetPlayer(); Player* plTarget = handler->getSelectedPlayer(); if (!plTarget) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); handler->SetSentErrorMessage(true); return false; } uint32 pclass = plTarget->getClass(); QueryResult result = WorldDatabase.PQuery("SELECT class FROM moderator_add WHERE id = %u AND type = 0", itemId); if (!result) { handler->PSendSysMessage("Item not found."); return true; } uint32 allowed_class = (*result)[0].GetUInt32(); if (allowed_class > 0 && pclass != allowed_class) { handler->PSendSysMessage("Player class not allowed to have this item."); return true; } sLog->outDetail(handler->GetTrinityString(LANG_ADDITEM), itemId, count); ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(itemId); if (!pProto) { handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); handler->SetSentErrorMessage(true); return false; } //Adding items uint32 noSpaceForCount = 0; // check space and find places ItemPosCountVec dest; InventoryResult msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= noSpaceForCount; if (count == 0 || dest.empty()) // can't add any { handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); handler->SetSentErrorMessage(true); return false; } Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); if (count > 0 && item) { pl->SendNewItem(item, count, false, true); if (pl != plTarget) plTarget->SendNewItem(item, count, true, false); } if (noSpaceForCount > 0) handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); return true; }
// Mysteria Star bool ChatHandler::HandleMarkCommand(char* args) { uint32 itemId = 38186; int32 count; // ak nieje parameter, pocet je defaultne 1 if (!*args) count = 1; else count = strtol(args, NULL, 10); // ak je vlozena hodnota chybna, vrati 0 if (count == 0) return false; // Ziskanie targetu hraca Player* pl = m_session->GetPlayer(); Player* plTarget = getSelectedPlayer(); // Ak nieje target, da Eventerovi samotnemu. //TODO: ma to vobec vyznam? if (!plTarget) plTarget = pl; // Sprava do Logu (len pri detajlnom log-ovani) sLog.outDetail(GetMangosString(LANG_ADDITEM), itemId, count); // Snaha vytvorit objekt (malo by sa podarit ale aj motyka vystreli...) ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemId); if (!pProto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); SetSentErrorMessage(true); return false; } // odobratie itemu (zaporny pocet) if (count < 0) { if (!plTarget->HasItemCount(itemId, -count, false)) // itemId, count, inBankAlso { ChatHandler(pl->GetSession()).PSendSysMessage("You do not have enough Mysteria Star!"); pl->GetSession()->SendNotification("You do not have enough Mysteria Star!"); return false; } plTarget->DestroyItemCount(itemId, -count, true, false); PSendSysMessage(LANG_REMOVEITEM, itemId, -count, GetNameLink(plTarget).c_str()); return true; } // Pridanie itemu uint32 noSpaceForCount = 0; // kontrola miesta v bagu a najdenie miesta ItemPosCountVec dest; uint8 msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= noSpaceForCount; if (count == 0 || dest.empty()) // can't add any { PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); SetSentErrorMessage(true); return false; } Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); // Odstranenie bindovania ak gm si da item sam aby ho mohol tradeovat // // TODO ma to vyznam? /* if(pl==plTarget) for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) if(Item* item1 = pl->GetItemByPos(itr->pos)) item1->SetBinding( false ); */ // Pridanie itemu if (count > 0 && item) { pl->SendNewItem(item, count, false, true); if (pl != plTarget) plTarget->SendNewItem(item, count, true, false); } // Chyba pri nedostatku miesta if (noSpaceForCount > 0) PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); return true; }
bool OPvPCapturePointNA::HandleCustomSpell(Player* player, uint32 spellId, GameObject* /*go*/) { std::vector<uint32> nodes; nodes.resize(2); bool retval = false; switch (spellId) { case NA_SPELL_FLY_NORTH: nodes[0] = FlightPathStartNodes[NA_ROOST_N]; nodes[1] = FlightPathEndNodes[NA_ROOST_N]; player->ActivateTaxiPathTo(nodes); player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP); player->UpdatePvP(true, true); retval = true; break; case NA_SPELL_FLY_SOUTH: nodes[0] = FlightPathStartNodes[NA_ROOST_S]; nodes[1] = FlightPathEndNodes[NA_ROOST_S]; player->ActivateTaxiPathTo(nodes); player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP); player->UpdatePvP(true, true); retval = true; break; case NA_SPELL_FLY_WEST: nodes[0] = FlightPathStartNodes[NA_ROOST_W]; nodes[1] = FlightPathEndNodes[NA_ROOST_W]; player->ActivateTaxiPathTo(nodes); player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP); player->UpdatePvP(true, true); retval = true; break; case NA_SPELL_FLY_EAST: nodes[0] = FlightPathStartNodes[NA_ROOST_E]; nodes[1] = FlightPathEndNodes[NA_ROOST_E]; player->ActivateTaxiPathTo(nodes); player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP); player->UpdatePvP(true, true); retval = true; break; default: break; } if (retval) { //Adding items uint32 noSpaceForCount = 0; // check space and find places ItemPosCountVec dest; int32 count = 10; uint32 itemid = 24538; // bomb id count InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= noSpaceForCount; if (count == 0 || dest.empty()) // can't add any { return true; } Item* item = player->StoreNewItem(dest, itemid, true); if (count > 0 && item) { player->SendNewItem(item, count, true, false); } return true; } return false; }
void SendDefaultMenu_custom_npc_tokenvendor(Player* pPlayer, Creature* pCreature, uint32 uiAction) { uint32 itemBoj = 29434; // Badge of Justice uint32 itemId2 = 23162; // 36 bag slot, I suppose ? (Darkiss) uint32 noSpaceForCount = 0; int32 count = 0; int32 count2 = 1; Item* item = NULL; ItemPosCountVec dest; ItemPosCountVec dest2; uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemBoj, 0); uint8 msg2 = pPlayer->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest2, 23162, 1); // Not allowed to use in combat if (pPlayer->isInCombat()) { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You are in combat", LANG_UNIVERSAL, NULL); return; } switch(uiAction) { case 2000: if(pPlayer->HasItemCount(itemBoj, 25 , true)) { pPlayer->CLOSE_GOSSIP_MENU(); pPlayer->DestroyItemCount(itemBoj, 25, true); pPlayer->ModifyMoney(+100000); pCreature->MonsterWhisper("You have just exchanged 25 BOJ to 10 Gold!", pPlayer->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens!", LANG_UNIVERSAL, NULL); } break; case 3000: if(pPlayer->HasItemCount(itemBoj, 40, true)) { pPlayer->CLOSE_GOSSIP_MENU(); pPlayer->DestroyItemCount(itemBoj, 40, true); pPlayer->GiveLevel(pPlayer->getLevel() + 1); pCreature->MonsterWhisper("You have just exchanged 40 BOJ for one level!", pPlayer->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens!", LANG_UNIVERSAL, NULL); } break; case 4000: if(pPlayer->HasItemCount(itemBoj, 20, true)) { if( msg != EQUIP_ERR_OK ) count2 -= noSpaceForCount; if( count2 == 0 || dest.empty()) { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterWhisper("Error: Item count set to 0. Please inform a GM about this error.", pPlayer->GetGUID()); } item = pPlayer->StoreNewItem( dest2, itemId2, true, Item::GenerateItemRandomPropertyId(itemId2)); if(count2 > 0 && item) { pPlayer->CLOSE_GOSSIP_MENU(); pPlayer->SendNewItem(item,count2,false,true); pPlayer->DestroyItemCount(itemBoj, 20, true); } if(noSpaceForCount > 0) { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterWhisper("You don't have enough free inventory slots", pPlayer->GetGUID()); } } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 5000: pPlayer->ADD_GOSSIP_ITEM(5,"Arcane Brilliance",GOSSIP_SENDER_MAIN,5001); pPlayer->ADD_GOSSIP_ITEM(5,"Greater Blessing of Kings",GOSSIP_SENDER_MAIN,5002); pPlayer->ADD_GOSSIP_ITEM(5,"Gift of the Wild",GOSSIP_SENDER_MAIN,5003); pPlayer->ADD_GOSSIP_ITEM(5,"Dalaran Brilliance",GOSSIP_SENDER_MAIN,5004); pPlayer->ADD_GOSSIP_ITEM(5,"Greater Blessing of Might",GOSSIP_SENDER_MAIN,5005); pPlayer->ADD_GOSSIP_ITEM(5,"Greater Blessing of Sanctuary",GOSSIP_SENDER_MAIN,5006); pPlayer->ADD_GOSSIP_ITEM(5,"Greater Blessing of Wisdom",GOSSIP_SENDER_MAIN,5007); pPlayer->ADD_GOSSIP_ITEM(5,"Prayer of Fortitude",GOSSIP_SENDER_MAIN,5008); pPlayer->ADD_GOSSIP_ITEM(5,"Prayer of Shadow Protection",GOSSIP_SENDER_MAIN,5009); pPlayer->ADD_GOSSIP_ITEM(5,"Prayer of Spirit",GOSSIP_SENDER_MAIN,5010); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); break; case 5001: if(pPlayer->HasItemCount(itemBoj,5,true)) { pPlayer->ADD_GOSSIP_ITEM(5,"<--Back",GOSSIP_SENDER_MAIN,5000); pPlayer->CastSpell(pPlayer,43002,true); pPlayer->DestroyItemCount(itemBoj, 5, true); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 5002: if(pPlayer->HasItemCount(itemBoj,5,true)) { pPlayer->ADD_GOSSIP_ITEM(5,"<--Back",GOSSIP_SENDER_MAIN,5000); pCreature->CastSpell(pPlayer,25898,false); pPlayer->DestroyItemCount(itemBoj,5,true); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 5003: if(pPlayer->HasItemCount(itemBoj,5,true)) { pPlayer->ADD_GOSSIP_ITEM(5,"<--Back",GOSSIP_SENDER_MAIN,5000); pPlayer->CastSpell(pPlayer,48470,true); pPlayer->DestroyItemCount(itemBoj,5,true); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 5004: if(pPlayer->HasItemCount(itemBoj,5,true)) { pPlayer->ADD_GOSSIP_ITEM(5,"<--Back",GOSSIP_SENDER_MAIN,5000); pPlayer->CastSpell(pPlayer,61316,true); pPlayer->DestroyItemCount(itemBoj,5,true); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 5005: if(pPlayer->HasItemCount(itemBoj,5,true)) { pPlayer->ADD_GOSSIP_ITEM(5,"<--Back",GOSSIP_SENDER_MAIN,5000); pCreature->CastSpell(pPlayer,48934,false); pPlayer->DestroyItemCount(itemBoj,5,true); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 5006: if(pPlayer->HasItemCount(itemBoj,5,true)) { pPlayer->ADD_GOSSIP_ITEM(5,"<--Back",GOSSIP_SENDER_MAIN,5000); pCreature->CastSpell(pPlayer,25899,false); pPlayer->DestroyItemCount(itemBoj,5,true); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 5007: if(pPlayer->HasItemCount(itemBoj,5,true)) { pPlayer->ADD_GOSSIP_ITEM(5,"<--Back",GOSSIP_SENDER_MAIN,5000); pCreature->CastSpell(pPlayer,48938,false); pPlayer->DestroyItemCount(itemBoj,5,true); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 5008: if(pPlayer->HasItemCount(itemBoj,5,true)) { pPlayer->ADD_GOSSIP_ITEM(5,"<--Back",GOSSIP_SENDER_MAIN,5000); pPlayer->CastSpell(pPlayer,48162,true); pPlayer->DestroyItemCount(itemBoj,5,true); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 5009: if(pPlayer->HasItemCount(itemBoj,5,true)) { pPlayer->ADD_GOSSIP_ITEM(5,"<--Back",GOSSIP_SENDER_MAIN,5000); pPlayer->CastSpell(pPlayer,48170,true); pPlayer->DestroyItemCount(itemBoj,5,true); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 5010: if(pPlayer->HasItemCount(itemBoj,5,true)) { pPlayer->ADD_GOSSIP_ITEM(5,"<--Back",GOSSIP_SENDER_MAIN,5000); pPlayer->CastSpell(pPlayer,48074,true); pPlayer->DestroyItemCount(itemBoj,5,true); pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 6000: if(pPlayer->HasItemCount(itemBoj, 10, true)) { if( msg != EQUIP_ERR_OK ) count2 -= noSpaceForCount; if( count2 == 0 || dest.empty()) { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterWhisper("Error: Item count set to 0. Please inform a GM about this error.", pPlayer->GetGUID()); } item = pPlayer->StoreNewItem( dest2, 90010, true, Item::GenerateItemRandomPropertyId(90010)); if(count2 > 0 && item) { pPlayer->CLOSE_GOSSIP_MENU(); pPlayer->SendNewItem(item,count2,false,true); pPlayer->DestroyItemCount(itemBoj, 10, true); } if(noSpaceForCount > 0) { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterWhisper("You don't have enough free inventory slots", pPlayer->GetGUID()); } } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 7000: if(pPlayer->HasItemCount(itemBoj, 10, true)) { if( msg != EQUIP_ERR_OK ) count2 -= noSpaceForCount; if( count2 == 0 || dest.empty()) { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterWhisper("Error: Item count set to 0. Please inform a GM about this error.", pPlayer->GetGUID()); } item = pPlayer->StoreNewItem( dest2, 90005, true, Item::GenerateItemRandomPropertyId(90005)); if(count2 > 0 && item) { pPlayer->CLOSE_GOSSIP_MENU(); pPlayer->SendNewItem(item,count2,false,true); pPlayer->DestroyItemCount(itemBoj, 10, true); } if(noSpaceForCount > 0) { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterWhisper("You don't have enough free inventory slots", pPlayer->GetGUID()); } } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; case 8000: if(pPlayer->HasItemCount(itemBoj, 10, true)) { if( msg != EQUIP_ERR_OK ) count2 -= noSpaceForCount; if( count2 == 0 || dest.empty()) { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterWhisper("Error: Item count set to 0. Please inform a GM about this error.", pPlayer->GetGUID()); } item = pPlayer->StoreNewItem( dest2, 8, true, Item::GenerateItemRandomPropertyId(8)); if(count2 > 0 && item) { pPlayer->CLOSE_GOSSIP_MENU(); pPlayer->SendNewItem(item,count2,false,true); pPlayer->DestroyItemCount(itemBoj, 10, true); } if(noSpaceForCount > 0) { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterWhisper("You don't have enough free inventory slots", pPlayer->GetGUID()); } } else { pPlayer->CLOSE_GOSSIP_MENU(); pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL); } break; } }
static bool HandleAddRPItemCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 itemId = 0; if (args[0] == '[') // [name] manual form { char* citemName = strtok((char*)args, "]"); if (citemName && citemName[0]) { std::string itemName = citemName+1; WorldDatabase.EscapeString(itemName); QueryResult result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE entry>200000 AND name = '%s'", itemName.c_str()); if (!result) { handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, citemName+1); handler->SetSentErrorMessage(true); return false; } itemId = result->Fetch()->GetUInt16(); } else return false; } else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r { char* cId = handler->extractKeyFromLink((char*)args,"Hitem"); if (!cId) return false; itemId = atol(cId); } if (itemId <200000) { handler->PSendSysMessage(LANG_COMMAND_RPITEMTOOLOW, itemId); handler->SetSentErrorMessage(true); return false; } char* ccount = strtok(NULL, " "); int32 count = 1; if (ccount) count = strtol(ccount, NULL, 10); if (count == 0) count = 1; Player* pl = handler->GetSession()->GetPlayer(); ItemPrototype const *pProto = sObjectMgr->GetItemPrototype(itemId); if (!pProto) { handler->PSendSysMessage(LANG_COMMAND_RPITEMIDINVALID, itemId); handler->SetSentErrorMessage(true); return false; } //Subtract if (count < 0) { pl->DestroyItemCount(itemId, -count, true, false); handler->PSendSysMessage(LANG_REMOVERPITEM, itemId, -count, handler->GetNameLink(pl).c_str()); return true; } //Adding items uint32 noSpaceForCount = 0; // check space and find places ItemPosCountVec dest; uint8 msg = pl->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= noSpaceForCount; if (count == 0 || dest.empty()) // can't add any { handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); handler->SetSentErrorMessage(true); return false; } Item* item = pl->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); if (count > 0 && item) { pl->SendNewItem(item,count,false,true); } if (noSpaceForCount > 0) handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); return true; }
void sendRewards() { QueryResult res = CharacterDatabase.PQuery("SELECT id,receiver,type,miscA,miscB,miscC,miscD FROM donations LEFT JOIN characters ON receiver=guid WHERE online=1"); if(res) { do { Field * field = res->Fetch(); uint32 id = field[0].GetUInt32(); uint32 receiver = field[1].GetUInt32(); uint32 type = field[2].GetUInt32(); uint32 misc[REWARD_SIZE]; misc[0] = field[3].GetUInt32(); misc[1] = field[4].GetUInt32(); misc[2] = field[5].GetUInt32(); misc[3] = field[6].GetUInt32(); Player * plr = sObjectAccessor->FindPlayer(receiver); if(!plr || !plr->IsInWorld()) continue; uint8 code = 0; SQLTransaction trans = CharacterDatabase.BeginTransaction(); switch(type) { case REWARD_TYPE_GOLD: plr->SetMoney(plr->GetMoney() + misc[0]); break; case REWARD_TYPE_RENAME: plr->SetAtLoginFlag(AT_LOGIN_RENAME); CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '1' WHERE guid = '%u'", plr->GetGUIDLow()); break; case REWARD_TYPE_CUSTOMIZE: plr->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE); CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '8' WHERE guid = '%u'", plr->GetGUIDLow()); break; case REWARD_TYPE_RACECHANGE: plr->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE); CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '128' WHERE guid = '%u'", plr->GetGUIDLow()); break; case REWARD_TYPE_FACTIONCHANGE: plr->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION); CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '64' WHERE guid = '%u'", plr->GetGUIDLow()); break; case REWARD_TYPE_SINGLEITEM: { for(int i = 0; i < REWARD_SIZE; i++) { if(misc[i] == 0) continue; ItemTemplate const* proto = sObjectMgr->GetItemTemplate(misc[i]); if(!proto) { code = 3; break; } ItemPosCountVec pos; uint32 extra = 0; uint8 r = plr->CanStoreNewItem(NULL_BAG, NULL_SLOT, pos, misc[i], 1, &extra); if(r != EQUIP_ERR_OK) { code = 4; MailSender sender(MAIL_NORMAL,plr->GetGUIDLow(),MAIL_STATIONERY_VAL); MailReceiver mailrecv(plr); MailDraft draft("Reward Delivery","Here is your reward."); Item * item = Item::CreateItem(misc[i],1); item->SaveToDB(trans); draft.AddItem(item); draft.SendMailTo(trans,mailrecv,sender); } else { Item * item = plr->StoreNewItem(pos,misc[i],true); plr->SendNewItem(item,1,true,false); } } } break; case REWARD_TYPE_MULTIITEM: { for(int i = 0; i < REWARD_SIZE; i = i + 2) { uint32 itemid = misc[i]; uint32 itemcount = misc[i+1]; if(itemid == 0 || itemcount == 0) continue; ItemTemplate const * proto = sObjectMgr->GetItemTemplate(itemid); if(!proto) { code = 3; break; } ItemPosCountVec pos; uint32 extra = 0; uint32 addcount = itemcount; uint8 r = plr->CanStoreNewItem(NULL_BAG,NULL_SLOT,pos,itemid,itemcount,&extra); if(r != EQUIP_ERR_OK) addcount = itemcount - extra; if(addcount == 0 || pos.empty()) { MailSender sender(MAIL_NORMAL,plr->GetGUIDLow(),MAIL_STATIONERY_VAL); MailReceiver mailrecv(plr); MailDraft draft("Reward Delivery","Here is your reward."); Item * item = Item::CreateItem(itemid,itemcount); item->SaveToDB(trans); draft.AddItem(item); draft.SendMailTo(trans,mailrecv,sender); item = plr->StoreNewItem(pos,itemid,true); plr->SendNewItem(item,addcount,true,false); code = 1; } else if(addcount != itemcount) { //some can't be sent, send the rest by mail MailSender sender(MAIL_NORMAL,plr->GetGUIDLow(),MAIL_STATIONERY_VAL); MailReceiver mailrecv(plr); MailDraft draft("Reward Delivery","Here is your reward."); Item * item = Item::CreateItem(itemid,itemcount - addcount); item->SaveToDB(trans); draft.AddItem(item); draft.SendMailTo(trans,mailrecv,sender); item = plr->StoreNewItem(pos,itemid,true); plr->SendNewItem(item,addcount,true,false); code = 4; } else if(addcount == itemcount) { //dont need to do anything but add plr->StoreNewItem(pos,itemid,true); } } } break; // case REWARD_TYPE_ITEMSET: // { // uint32 set = misc[0]; // if(set == 0) // { // code = 2; // break; // } // for(int i = 0; i < sItemSetStore.GetNumRows; i++) // { //ItemTemplate const* proto = sObjectMgr->GetItemTemplate(id); //if(!proto) //continue; //if(proto->ItemSet == set) //{ //ItemPosCountVec pos; //uint8 r = plr->CanStoreNewItem(NULL_BAG,NULL_SLOT,pos,proto->ItemId,1); //if(r != EQUIP_ERR_OK) //{ //code = 1; //MailSender sender(MAIL_NORMAL,plr->GetGUIDLow(),MAIL_STATIONERY_VAL); //MailReceiver mailrecv(plr); //MailDraft draft("Reward Delivery","Here is your reward."); //Item * item = Item::CreateItem(i,1); //item->SaveToDB(trans); //draft.AddItem(item); //draft.SendMailTo(trans,mailrecv,sender); //} //else //{ //Item * item = plr->StoreNewItem(pos,proto->ItemId,true); //plr->SendNewItem(item,1,true,false); //} // } // } // } break; case REWARD_TYPE_LEVEL: plr->SetLevel( plr->getLevel() + misc[0] > 80 ? 80 : plr->getLevel() + misc[0] ); break; case REWARD_TYPE_TITLE: { CharTitlesEntry const* entry = sCharTitlesStore.LookupEntry(misc[0]); if(!entry) { code = 2; break; } plr->SetTitle(entry); } break; case REWARD_TYPE_SPELL: plr->learnSpell(misc[0],false); break; case REWARD_TYPE_SKILL: { //SkillLineEntry const* entry = sSkillLineStore.LookupEntry(misc[0]); //if(!entry) //{ code = 2; // break; //} //plr->SetSkill(misc[0],misc[1],400); } break; case REWARD_TYPE_REPUTATION: { FactionEntry const* entry = sFactionStore.LookupEntry(misc[0]); if(!entry) { code = 2; break; } plr->SetReputation(entry->ID,misc[1]); } break; } WorldPacket data; switch(code) { default: ChatHandler::FillMessageData(&data, plr->GetSession(), CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, "Thank you for your support. Enjoy your reward!", NULL); break; case 1: ChatHandler::FillMessageData(&data, plr->GetSession(), CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, "Thank you for your support. Your reward has been mailed to you.", NULL); break; case 2: ChatHandler::FillMessageData(&data, plr->GetSession(), CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, "|cffff0000Warning: Your reward could not be granted. Will try again later. :(|r", NULL); break; case 3: ChatHandler::FillMessageData(&data, plr->GetSession(), CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, "|cffff0000Warning: Your reward could not be granted. :(|r", NULL); break; case 4: ChatHandler::FillMessageData(&data, plr->GetSession(), CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, "Thank you for your support. You now have parts of your reward, the rest will arrive via mail.", NULL); break; } plr->GetSession()->SendPacket(&data); if(code != 2) CharacterDatabase.PExecute("DELETE FROM donations WHERE id = %u",id); plr->CastSpell(plr,19484,true); CharacterDatabase.CommitTransaction(trans); } while(res->NextRow()); } }