bool ChatHandler::HandleAddVendorItemCommand(const char* args) { if (!*args) return false; Creature* vendor = getSelectedCreature(); if (!vendor || !vendor->isVendor()) { SendSysMessage("You must select vendor"); return true; } char* pitem = strtok((char*)args, " "); uint32 itemId = atol(pitem); if (!pitem) { SendSysMessage("You must send id for item"); return true; } char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0 uint32 maxcount = 0; if (fmaxcount) maxcount = atol(fmaxcount); char* fincrtime = strtok(NULL, " "); //add incrtime, default: 0 uint32 incrtime = 0; if (fincrtime) incrtime = atol(fincrtime); ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); if(!pProto) { PSendSysMessage(LANG_ITEM_NOT_FOUND, itemId); return true; } if(vendor->FindItem(itemId)) { PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST,itemId); return true; } if (vendor->GetItemCount() >= MAX_CREATURE_ITEMS) { SendSysMessage("Vendor has too many items (max 128)"); return true; } // add to DB and to current ingame vendor sDatabase.PExecuteLog("INSERT INTO `npc_vendor` (`entry`,`item`,`maxcount`,`incrtime`) VALUES('%u','%u','%u','%u')",vendor->GetEntry(), itemId, maxcount,incrtime); vendor->AddItem(itemId,maxcount,incrtime); PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime); return false; }