- Mesaj
- 277
- Çözümler
- 19
- Beğeni
- 206
- Puan
- 414
- Ticaret Puanı
- 0
Merhaba arkadaşlar grid offline shop için item arama sistemini uyarlamak istedim ama bir türlü işaretlemeyi yapamadım
buradaki item aramayı aldım
Linkleri görebilmek için
giriş yap veya kayıt ol.
buradaki item aramayı aldım
Kod:
void CShopManager::SearchInShops(LPCHARACTER ch, int vnum)
{
if (!ch)
return;
if (!CheckSearchTime(ch->GetPlayerID()))
{
SendChatPacket(ch, CHAT_PACKET_CANNOT_SEARCH_YET);
return;
}
int foundCount = 0;
for (auto& kv : m_mapShops)
{
CShop& shop = kv.second;
CShop::VECSHOPITEM* items = shop.GetItems();
if (!items)
continue;
for (const auto& shopItem : *items)
{
TItemTable* table = nullptr;
if (!shopItem.GetTable(&table))
continue;
if ((int)table->dwVnum == vnum)
{
DWORD ownerPID = shop.GetOwnerPID();
sys_log(0, "SearchInShops: Checking shop for Owner PID: %u", ownerPID);
char shopQuery[512];
snprintf(shopQuery, sizeof(shopQuery),
"SELECT name, pos_x, pos_y, map_index FROM player.offlineshop_shops WHERE owner_id = %u",
ownerPID);
std::unique_ptr<SQLMsg> shopMsg(DBManager::instance().DirectQuery(shopQuery));
if (shopMsg->Get()->uiNumRows > 0)
{
MYSQL_ROW shopRow = mysql_fetch_row(shopMsg->Get()->pSQLResult);
const char* shopName = shopRow[0] ? shopRow[0] : "Bilinmeyen Shop";
long pos_x = shopRow[1] ? strtol(shopRow[1], nullptr, 10) : 0;
long pos_y = shopRow[2] ? strtol(shopRow[2], nullptr, 10) : 0;
long map_index = shopRow[3] ? strtol(shopRow[3], nullptr, 10) : 0;
CTargetManager::Instance().CreateTarget(
ch->GetPlayerID(),
9999,
shopName,
3,
pos_x,
pos_y,
map_index,
NULL,
1
);
sys_log(0, "SearchInShops: Shop found - Owner PID: %u, Name: %s, MapIndex: %ld, Pos: %ld,%ld",
ownerPID, shopName, map_index, pos_x, pos_y);
ch->ChatPacket(CHAT_TYPE_INFO, "Bulundu: %s (MapIndex: %d, Pos: %ld,%ld)",
shopName, map_index, pos_x, pos_y);
}
else
{
sys_err("SearchInShops: No shop found for Owner PID: %u, SQL Error: %ld", ownerPID,
shopMsg->uiSQLErrno);
ch->ChatPacket(CHAT_TYPE_INFO, "Shop bilgileri bulunamadı (Owner PID: %u)", ownerPID);
}
foundCount++;
break;
}
}
}
if (foundCount == 0)
ch->ChatPacket(CHAT_TYPE_INFO, "Hiç eşleşme bulunamadı.");
else
ch->ChatPacket(CHAT_TYPE_INFO, "%d adet eşleşme bulundu.", foundCount);
m_searchTimeMap[ch->GetPlayerID()] = (DWORD)time(nullptr);
}