Merhaba.
cevaplara bakıyorum da saçma sapan gereksiz cevaplar var adama yardımcı olmak yerine beynini iyicene sulandırıyorsunuz. tek adam akıllı cevap veren
@nxwile olmuş adamı doğru yönlendirdiğin için teşekkürler.
verdiğin gamemaster kod satırını inceledim sadece +merchantbotspawn sIndex sIndex üzerinden işlem yapıyor void içerisine girdiğimde
C++:
COMMAND_HANDLER(CUser::HandleBotSpawnMerchant)
{
if (!isGM())
return false;
if (vargs.size() < 1)
{
// send description
g_pMain->SendHelpDescription(this, "Using Sample : +merchantbotspawn sIndex");
return true;
}
DateTime time;
int sIndex = 0;
sIndex = atoi(vargs.front().c_str());
uint16 m_sSocketID = g_pMain->SpawnEventBotMerchant(3600, GetZoneID(), GetX(), GetY(), GetZ(), 0, MIN_LEVEL_ARDREAM);
CBot* pBot = g_pMain->GetBotPtr(m_sSocketID);
if (pBot == nullptr)
return true;
_BOT_MERCHANT_ITEM* pBotMerchantTable = g_pMain->m_ArtificialMerchantArray.GetData(sIndex);
if (pBotMerchantTable == nullptr)
{
pBot->UserInOut(INOUT_OUT);
g_pMain->RemoveMapBotList(pBot->GetID(), pBot->GetName());
return true;
}
pBot->m_bPremiumMerchant = (bool)pBotMerchantTable->BotMerchantType;
Packet result(WIZ_MERCHANT, uint8(MERCHANT_INSERT));
result << uint16(1) << pBotMerchantTable->BotMerchantMessage << pBot->GetID()
<< pBot->m_bPremiumMerchant;
if (!pBotMerchantTable->BotMerchantMessage.empty())
pBot->MerchantChat = string_format("%s(Location:%d,%d)", pBotMerchantTable->BotMerchantMessage.c_str(), pBot->GetSPosX() / 10, pBot->GetSPosZ() / 10);
else
pBot->MerchantChat.clear();
uint16 totalMerchItems = 0;
for (int t = 0; t < MAX_MERCH_ITEMS; t++)
{
pBot->m_arMerchantItems[t].bCount = pBotMerchantTable->m_MerchantItems[t].bCount;
pBot->m_arMerchantItems[t].bOriginalSlot = pBotMerchantTable->m_MerchantItems[t].bOriginalSlot;
pBot->m_arMerchantItems[t].IsSoldOut = pBotMerchantTable->m_MerchantItems[t].IsSoldOut;
pBot->m_arMerchantItems[t].nNum = pBotMerchantTable->m_MerchantItems[t].nNum;
pBot->m_arMerchantItems[t].nPrice = pBotMerchantTable->m_MerchantItems[t].nPrice;
pBot->m_arMerchantItems[t].nSerialNum = pBotMerchantTable->m_MerchantItems[t].nSerialNum;
pBot->m_arMerchantItems[t].sCount = pBotMerchantTable->m_MerchantItems[t].sCount;
pBot->m_arMerchantItems[t].sDuration = pBotMerchantTable->m_MerchantItems[t].sDuration;
if (pBot->m_arMerchantItems[t].nNum != 0 &&
(pBot->m_arMerchantItems[t].bCount == 0
|| pBot->m_arMerchantItems[t].bCount < pBotMerchantTable->m_MerchantItems[t].sCount))
continue;
result << pBot->m_arMerchantItems[t].nNum;
if (pBot->m_arMerchantItems[t].nNum > 0)
totalMerchItems++;
}
if (totalMerchItems == 0)
{
result.clear();
result.Initialize(WIZ_MERCHANT);
result << uint8(MERCHANT_CLOSE) << pBot->GetID();
pBot->SendToRegion(&result);
pBot->UserInOut(INOUT_OUT);
g_pMain->RemoveMapBotList(pBot->GetID(), pBot->GetName());
return true;
}
pBot->m_bMerchantState = MERCHANT_STATE_SELLING;
pBot->SendToRegion(&result);
MerchantClose();
return true;
}
_BOT_MERCHANT_ITEM üzerinden işlem yaptığını gördüm burayı projede araştırdığımda
C++:
bool CDBAgent::LoadBotHandlerMerchantTable()
{
unique_ptr<OdbcCommand> dbCommand(m_GameDB->CreateCommand());
if (dbCommand.get() == nullptr)
{
printf("Load Open LOAD_BOT_HANDLER_MERCHANT Error: 1\n");
return false;
}
if (!dbCommand->Execute(_T("{CALL LOAD_BOT_HANDLER_MERCHANT}")))
{
ReportSQLError(m_GameDB->GetError());
printf("Load Open LOAD_BOT_HANDLER_MERCHANT Error: 2\n");
return false;
}
if (!dbCommand->hasData())
{
printf("Load Open LOAD_BOT_HANDLER_MERCHANT Error: 3\n");
return false;
}
do
{
_BOT_MERCHANT_ITEM* pBotMerchant = new _BOT_MERCHANT_ITEM();
int field = 1;
dbCommand->FetchUInt32(field++, pBotMerchant->sIndex);
dbCommand->FetchByte(field++, pBotMerchant->BotMerchantType);
dbCommand->FetchString(field++, pBotMerchant->BotItemNum);
dbCommand->FetchString(field++, pBotMerchant->BotItemCount);
dbCommand->FetchString(field++, pBotMerchant->BotItemPrice);
dbCommand->FetchString(field++, pBotMerchant->BotMerchantMessage);
memset(&pBotMerchant->m_MerchantItems, 0, sizeof(pBotMerchant->m_MerchantItems));
std::list<std::string> sItemNum = StrSplit(pBotMerchant->BotItemNum, ",");
std::list<std::string> sItemCount = StrSplit(pBotMerchant->BotItemCount, ",");
std::list<std::string> sItemPrice = StrSplit(pBotMerchant->BotItemPrice, ",");
uint8 nItemNum = (uint8)sItemNum.size();
uint8 nItemCount = (uint8)sItemCount.size();
uint8 nItemPrice = (uint8)sItemPrice.size();
if (nItemNum > 0 && nItemCount > 0 && nItemPrice > 0)
{
uint32 bItemNum = 0;
uint16 bItemCount = 0;
uint32 bItemPrice = 0;
for (int i = 0; i < nItemNum; i++)
{
bItemNum = atoi(sItemNum.front().c_str());
bItemCount = atoi(sItemCount.front().c_str());
bItemPrice = atoi(sItemPrice.front().c_str());
if (bItemNum > 0 && bItemCount > 0 && bItemPrice > 0)
{
_ITEM_TABLE pTable = g_pMain->GetItemPtr(bItemNum);
if (pTable.isnull()
|| bItemNum >= ITEM_NO_TRADE_MIN && bItemNum <= ITEM_NO_TRADE_MAX // Cannot be traded, sold or stored.
|| pTable.m_bRace == RACE_UNTRADEABLE // Cannot be traded or sold.
|| (pTable.m_bKind == 255 && bItemCount != 1)) // Cannot be traded or sold.
continue;
pBotMerchant->m_MerchantItems[i].nNum = bItemNum;
pBotMerchant->m_MerchantItems[i].nPrice = bItemPrice;
pBotMerchant->m_MerchantItems[i].sCount = bItemCount; // Selling Count
if (pTable.m_bKind == 255)
pBotMerchant->m_MerchantItems[i].bCount = bItemCount; // Original Count ( INVENTORY )
else
pBotMerchant->m_MerchantItems[i].bCount = bItemCount; // Original Count ( INVENTORY )
if (pTable.m_bCountable > 0)
pBotMerchant->m_MerchantItems[i].bCount = bItemCount; // Original Count ( INVENTORY )
else
pBotMerchant->m_MerchantItems[i].bCount = 1; // Original Count ( INVENTORY )
pBotMerchant->m_MerchantItems[i].sDuration = pTable.m_sDuration;
pBotMerchant->m_MerchantItems[i].nSerialNum = g_pMain->GenerateItemSerial(); // NOTE: Stackable items will have an issue with this.
pBotMerchant->m_MerchantItems[i].bOriginalSlot = i;
pBotMerchant->m_MerchantItems[i].IsSoldOut = false;
}
sItemNum.pop_front();
sItemCount.pop_front();
sItemPrice.pop_front();
}
}
if (!g_pMain->m_ArtificialMerchantArray.PutData(pBotMerchant->sIndex, pBotMerchant))
delete pBotMerchant;
} while (dbCommand->MoveNext());
return true;
}
GameServer açılır açılmaz _BOT_MERCHANT_ITEM load yaptığını fark ettim LOAD_BOT_HANDLER_MERCHANT prosedüre bakarak BOT_HANDLER_MERCHANT tablodan botları okuduğunu fark ettim tabloyu incelediğimde
Ekli dosyayı görüntüle 3698
bu şekilde olduğunu fark ettim oyunda GameMaster karakterle girdiğimde +merchantbotspawn 52 yazdığımda tabloda sIndex 52 olan itemli şekilde yanıma bot atığımı fark ettim sonuç olarak +merchantbotspawn sIndex yaptıgında sIndex yazan yere BOT_HANDLER_MERCHANT tablosundaki sIndex yazıcaksınız .
yardımcı olduysam ne mutlu bana