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; }