Jump to content

Shop search edit


Recommended Posts

How i can modify this code from this:

DDkYjoI.jpg

To this:

6TVd9Wn.jpg

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] No ha colocado ninguno nombre.");
		return;
	}
	if (Item_Gold < 0){
		ch->ChatPacket(CHAT_TYPE_INFO,"[Shop Search] Coloque un valor mayor a 0");
		return;
	}
	if (Item_Gold > 2000000000){
		ch->ChatPacket(CHAT_TYPE_INFO,"[Shop Search] Coloque un valor menos de 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 se encuentra ningun item con ese nombre.");
			return;
		}
		if (Item_Gold > 0){
			if(check_0 == 0){
				ch->ChatPacket(CHAT_TYPE_INFO,"[Shop Search] No existe ningun item con ese valor.");
				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");
				}
			}
		}
	}
}

Best regards.

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 2

      Feeding game source to LLM

    2. 0

      Target Information System

    3. 2

      Feeding game source to LLM

    4. 2

      anti exp explanation pls

    5. 2

      Feeding game source to LLM

    6. 2

      anti exp explanation pls

    7. 0

      [GR2] Positioning an object added with "Attach"

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.