本文整理汇总了C++中Creature::AddVendorItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Creature::AddVendorItem方法的具体用法?C++ Creature::AddVendorItem怎么用?C++ Creature::AddVendorItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Creature
的用法示例。
在下文中一共展示了Creature::AddVendorItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleItemCommand
bool ChatHandler::HandleItemCommand(const char* args, WorldSession *m_session)
{
char* pitem = strtok((char*)args, " ");
if (!pitem)
return false;
uint64 guid = m_session->GetPlayer()->GetSelection();
if (guid == 0)
{
SystemMessage(m_session, "No selection.");
return true;
}
Creature * pCreature = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(!pCreature)
{
SystemMessage(m_session, "You should select a creature.");
return true;
}
uint32 item = atoi(pitem);
int amount = -1;
char* pamount = strtok(NULL, " ");
if (pamount)
amount = atoi(pamount);
ItemPrototype* tmpItem = ItemPrototypeStorage.LookupEntry(item);
std::stringstream sstext;
if(tmpItem)
{
std::stringstream ss;
ss << "INSERT INTO vendors VALUES ('" << pCreature->GetUInt32Value(OBJECT_FIELD_ENTRY) << "', '" << item << "', '" << amount << "', 0, 0 )" << '\0';
WorldDatabase.Execute( ss.str().c_str() );
pCreature->AddVendorItem(item, amount);
sstext << "Item '" << item << "' '" << tmpItem->Name1 << "' Added to list" << '\0';
}
else
{
sstext << "Item '" << item << "' Not Found in Database." << '\0';
}
sGMLog.writefromsession(m_session, "added item %u to vendor %u", pCreature->GetEntry(), item);
SystemMessage(m_session, sstext.str().c_str());
return true;
}
示例2: HandleItemCommand
bool ChatHandler::HandleItemCommand(const char* args, WorldSession *m_session)
{
if(strlen(args) < 1)
return false;
Creature* pCreature = getSelectedCreature(m_session, false);
if(!pCreature || !pCreature->m_spawn || !(pCreature->HasNpcFlag(UNIT_NPC_FLAG_VENDOR) || pCreature->HasNpcFlag(UNIT_NPC_FLAG_ARMORER)))
{
SystemMessage(m_session, "You should select a vendor.");
return true;
}
int amount = 1;
uint32 item = 0, extendedcost = 0, vendormask = 0;
if(sscanf(args, "%u %u %u %u", &item, &amount, &extendedcost, &vendormask) < 1)
{
// check for item link
GetItemIDFromLink(args, &item);
if(item == 0)
return false;
}
if(item == 0)
return false;
if(vendormask == 0)
vendormask = pCreature->m_spawn->vendormask;
ItemPrototype* tmpItem = ItemPrototypeStorage.LookupEntry(item);
std::stringstream sstext;
if(tmpItem)
{
std::stringstream ss;
ss << "INSERT INTO vendors(entry, item, amount, extendedcost, vendormask) VALUES ('" << pCreature->GetEntry() << "', '" << item << "', '" << amount << "', " << extendedcost << ", " << vendormask << " );";
WorldDatabase.Execute( ss.str().c_str() );
pCreature->AddVendorItem(item, amount, vendormask, extendedcost);
sstext << "Item '" << item << "' '" << tmpItem->Name1 << "' Added to list" << '\0';
}
else
sstext << "Item '" << item << "' Not Found in Database." << '\0';
sWorld.LogGM(m_session, "added item %u to vendor %u", item, pCreature->GetEntry());
SystemMessage(m_session, sstext.str().c_str());
return true;
}
示例3: HandleItemCommand
bool ChatHandler::HandleItemCommand(const char* args, WorldSession* m_session)
{
char* pitem = strtok((char*)args, " ");
if(!pitem)
return false;
uint64 guid = m_session->GetPlayer()->GetSelection();
if(guid == 0)
{
SystemMessage(m_session, "No selection.");
return true;
}
Creature* pCreature = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(!pCreature)
{
SystemMessage(m_session, "You should select a creature.");
return true;
}
uint32 item = atoi(pitem);
int amount = -1;
char* pamount = strtok(NULL, " ");
if(pamount)
amount = atoi(pamount);
if(amount == -1)
{
SystemMessage(m_session, "You need to specify an amount.");
return true;
}
uint32 costid = 0;
char* pcostid = strtok(NULL, " ");
if(pcostid)
costid = atoi(pcostid);
ItemExtendedCostEntry* ec = (costid > 0) ? dbcItemExtendedCost.LookupEntryForced(costid) : NULL;
if(costid > 0 && dbcItemExtendedCost.LookupEntryForced(costid) == NULL)
{
SystemMessage(m_session, "You've entered invalid extended cost id.");
return true;
}
ItemPrototype* tmpItem = ItemPrototypeStorage.LookupEntry(item);
std::stringstream sstext;
if(tmpItem)
{
std::stringstream ss;
ss << "INSERT INTO vendors VALUES ('" << pCreature->GetEntry() << "', '" << item << "', '" << amount << "', 0, 0, " << costid << " )" << '\0';
WorldDatabase.Execute(ss.str().c_str());
pCreature->AddVendorItem(item, amount, ec);
sstext << "Item '" << item << "' '" << tmpItem->Name1 << "' Added to list";
if(costid > 0)
sstext << "with extended cost " << costid;
sstext << '\0';
}
else
{
sstext << "Item '" << item << "' Not Found in Database." << '\0';
}
sGMLog.writefromsession(m_session, "added item %u to vendor %u", item, pCreature->GetEntry());
SystemMessage(m_session, sstext.str().c_str());
return true;
}
示例4: HandleItemSetCommand
bool ChatHandler::HandleItemSetCommand(const char* args, WorldSession *m_session)
{
if(strlen(args) < 1)
return false;
uint64 guid = m_session->GetPlayer()->GetSelection();
if(guid == 0)
{
SystemMessage(m_session, "No selection.");
return true;
}
Creature* pCreature = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(!pCreature)
{
SystemMessage(m_session, "You should select a creature.");
return true;
}
if(!pCreature->m_spawn)
{
SystemMessage(m_session, "You should select a saved creature.");
return true;
}
int32 vendormask = 0, extendedcost = 0;
uint32 setid, rank = 1, amount = 1, count = 0;
if(sscanf(args, "%u %u %u %i %i", &setid, &rank, &amount, &extendedcost, &vendormask) < 1)
{
RedSystemMessage(m_session, "You must specify a setid.");
return true;
}
std::list<ItemPrototype*>* l = objmgr.GetListForItemSet(setid);
if(l == NULL)
{
RedSystemMessage(m_session, "Invalid item set.");
return true;
}
if(vendormask == 0)
vendormask = pCreature->m_spawn->vendormask;
std::stringstream sstext;
for(std::list<ItemPrototype*>::iterator itr = l->begin(); itr != l->end(); itr++)
{
if((*itr)->ItemSetRank && (*itr)->ItemSetRank != rank)
continue;
std::stringstream ss;
ss << "INSERT INTO vendors(entry, item, amount, extendedcost, vendormask) VALUES ('" << pCreature->GetEntry() << "', '" << (*itr)->ItemId << "', '" << amount << "', " << extendedcost << ", " << vendormask << " );";
WorldDatabase.Execute( ss.str().c_str() );
pCreature->AddVendorItem((*itr)->ItemId, amount, vendormask, extendedcost);
count++;
}
if(count)
{
sstext << "Item set '" << setid << "' rank '" << rank << "' Added to vendor." << '\0';
sWorld.LogGM(m_session, "added item set %u rank %u to vendor %u", setid, rank, pCreature->GetEntry());
SystemMessage(m_session, sstext.str().c_str());
}
else
RedSystemMessage(m_session, "No items found");
return true;
}