I thank you to all the people who have taken effort in solving my issue.
meneleos special thank to you.
Its working now
But another bug
Th search is case sensitive, it shows the items only when I type the exact word
For example if I search "Sword" it shows list of swords. A screenshot below
[Hidden Content]
But If I type "sword" the list doesnt appears
My search code is here
void CInputMain::PrivateSearch(LPCHARACTER ch, const char * data)
{
struct packet_private_search * pinfo = (struct packet_private_search *) data;
const char* Item_Search = pinfo->item_name; //Nombre Recibido
int Item_Gold = pinfo->item_gold;
if (strlen(Item_Search) == 0){
ch->ChatPacket(CHAT_TYPE_INFO,"[Shop Search] Type any name.");
return;
}
if (Item_Gold < 0){
ch->ChatPacket(CHAT_TYPE_INFO,"[Shop Search] Set a value greater than 0");
return;
}
if (Item_Gold > 2000000000){
ch->ChatPacket(CHAT_TYPE_INFO,"[Shop Search] Place a value less than 2kkk");
return;
}
int check = 0;
int check_0 = 0;
char szQuery[1024];
snprintf(szQuery, sizeof(szQuery),"SELECT * FROM player.offline_shop_item WHERE status=0 and mapIndex=%d",ch->GetMapIndex());
std::auto_ptr<SQLMsg> pMsg(DBManager::Instance().DirectQuery(szQuery));
std::auto_ptr<SQLMsg> pMsg1(DBManager::Instance().DirectQuery(szQuery));
if (pMsg->Get()->uiNumRows > 0)
{
//Check si no existe ningun item con ese nombre
while (MYSQL_ROW row_check = mysql_fetch_row(pMsg1->Get()->pSQLResult))
{
const char * Item_Totales_0 = row_check[43]; //Nombres Tablas
const char * Item_Vnums_0 = row_check[4]; //Vnums Tablas
const char * Item_Gold_0 = row_check[41]; //Gold Tablas
DWORD Vnum_Item_0 = 0;
str_to_number(Vnum_Item_0, Item_Vnums_0); //Convierte el vnum de string a numero entero
int Gold_Item_0 = 0;
str_to_number(Gold_Item_0, Item_Gold_0); //Convierte el vnum de string a numero entero
if (strstr(Item_Totales_0, Item_Search)){
check++;
}
if (Item_Gold > 0){
if (Gold_Item_0 <= Item_Gold){
check_0++;
}
}
}
if(check == 0){
ch->ChatPacket(CHAT_TYPE_INFO,"[Shop Search] No item with that name is found.");
return;
}
if (Item_Gold > 0){
if(check_0 == 0){
ch->ChatPacket(CHAT_TYPE_INFO,"[Shop Search] There is no item with that value.");
return;
}
}
while (MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult))
{
const char * Item_Totales = row[43]; //Nombres Tablas
const char * Item_Vnums = row[4]; //Vnums Tablas
const char * Item_Gold_1 = row[41]; //Gold Tablas
DWORD Vnum_Item = 0;
str_to_number(Vnum_Item, Item_Vnums); //Convierte el vnum de string a numero entero
int Gold_Item = 0;
str_to_number(Gold_Item, Item_Gold_1); //Convierte el vnum de string a numero entero
if (strstr(Item_Totales, Item_Search)){
if (Item_Gold > 0){
if (Gold_Item <= Item_Gold){
ch->ChatPacket(CHAT_TYPE_COMMAND, "PrivateSearch_ItemsSearch %d",Vnum_Item);
ch->ChatPacket(CHAT_TYPE_COMMAND, "PrivateSearch_RefreshItems");
}
}else{
ch->ChatPacket(CHAT_TYPE_COMMAND, "PrivateSearch_ItemsSearch %d",Vnum_Item);
ch->ChatPacket(CHAT_TYPE_COMMAND, "PrivateSearch_RefreshItems");
}
}
}
}
}