本文整理汇总了C++中Player::AddNewInventoryItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Player::AddNewInventoryItem方法的具体用法?C++ Player::AddNewInventoryItem怎么用?C++ Player::AddNewInventoryItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::AddNewInventoryItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleCharCreate
void WorldSession::HandleCharCreate( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 1+1+1+1+2+2+2+2+1+1+1+1+1+1+1+1);
Player * pNewChar = new Player(this);
// prevent character creating with invalid name
if(new_name.empty())
{
sLog.outError("Account:[%d] but tried to Create character with empty [name]", GetAccountId());
return;
}
std::string pass1;
std::string pass2;
if(pNewChar->Create( objmgr.GenerateLowGuid(HIGHGUID_PLAYER), new_name, recv_data, pass1, pass2 ))
{
Item* shirt = pNewChar->CreateItem( 864, 1 );
if( shirt )
{
uint8 slot = shirt->GetProto()->EquipmentSlot;
uint8 dest = slot;
if( pNewChar->CanEquipItem( slot, dest, shirt, false ) == EQUIP_ERR_OK )
pNewChar->EquipItem( dest, shirt, false );
else
delete shirt;
}
///- Add level 1 survival gears
pNewChar->AddNewInventoryItem( 10012, 1 );
pNewChar->AddNewInventoryItem( 19001, 1 );
pNewChar->AddNewInventoryItem( 20711, 1 );
pNewChar->AddNewInventoryItem( 21011, 1 );
pNewChar->AddNewInventoryItem( 22401, 1 );
///- Adding default pet (Guo Jia evo)
/*
Pet* pet = pNewChar->CreatePet( 3402 );
if( pet )
{
uint8 slot = 0;
uint8 dest = slot;
if( pNewChar->CanSummonPet( slot, dest, pet, false ) == PET_ERR_OK )
pNewChar->SummonPet( 0, pet );
else
delete pet;
}
*/
pNewChar->SaveToDB();
delete pNewChar;
}
else
{
// Player not create (problem?)
delete pNewChar;
///- TODO: Send char create error to client
return;
}
std::string md5pass1 = md5(pass1);
std::string md5pass2 = md5(pass2);
///- Commit pending player creation transaction, for login preparation
loginDatabase.PExecute("UPDATE accounts SET md5pass1 = '%s', md5pass2 = '%s' WHERE accountid = %u", md5pass1.c_str(), md5pass2.c_str(), GetAccountId());
CharacterDatabase.CommitTransaction();
///- do a small delay to make sure player save to database completed
ZThread::Thread::sleep(10);
std::string IP_str = _socket ? _socket->GetRemoteAddress().c_str() : "-";
sLog.outString("Account: %d (IP: %s) Create Character:[%s]", GetAccountId(), IP_str.c_str(), new_name.c_str());
sLog.outChar("Account: %d (IP: %s) Create Character:[%s]", GetAccountId(), IP_str.c_str(), new_name.c_str());
///- Clear new name after new player creation
new_name = "";
WorldPacket data;
data << (uint8 ) pass1.size();
data << (uint32) GetAccountId();
data << (uint32) 0x00;
data << pass1;
HandlePlayerLoginOpcode( data );
}