Jump to content
  • 0

@whobuy Error


Question

Posted

 

/*==========================================
* @whobuy - List who is buying the item (amount, price, and location).
* remake by VoidLess, original by zephyrus_cr
* re-edit by deathscythe to work in rAthena
*------------------------------------------*/
ACMD_FUNC(whobuy)
{
	char item_name[100];
	int item_id, j, count = 0, sat_num = 0;
	bool flag = 0; // place dot on the minimap?
	struct map_session_data* pl_sd;
	struct s_mapiterator* iter;
	unsigned int MinPrice = battle_config.vending_max_value, MaxPrice = 0;
	struct item_data *item_data;

	nullpo_retr(-1, sd);
	memset(item_name, '\0', sizeof(item_name));

	if (!message || !*message || sscanf(message, "%99[^\n]", item_name) < 1) {
		clif_displaymessage(fd, "Input item name or ID (use: @whobuy <name or ID>).");
		return -1;
	}
	if ((item_data = itemdb_searchname(item_name)) == NULL &&
		(item_data = itemdb_exists(atoi(item_name))) == NULL)
	{
		clif_displaymessage(fd, msg_txt(sd, 19)); // Invalid item ID or name.
		return -1;
	}

	item_id = item_data->nameid;

	iter = mapit_getallusers();
	for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter))
	{
		if (pl_sd->state.buyingstore) //check if player is autobuying
		{
			for (j = 0; j < pl_sd->buyingstore.slots; j) {
				if (pl_sd->buyingstore.items[j].nameid == item_id) {
					snprintf(atcmd_output, CHAT_SIZE_MAX, "Price %d | Amount %d | Buyer %s | Map %s[%d,%d]", pl_sd->buyingstore.items[j].price, pl_sd->buyingstore.items[j].amount, pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
					if (pl_sd->buyingstore.items[j].price < MinPrice) MinPrice = pl_sd->buyingstore.items[j].price;
					if (pl_sd->buyingstore.items[j].price > MaxPrice) MaxPrice = pl_sd->buyingstore.items[j].price;
					clif_displaymessage(fd, atcmd_output);
					count;
					flag = 1;
				}
			}
			if (flag && pl_sd->mapindex == sd->mapindex) {
				clif_viewpoint(sd, 1, 1, pl_sd->bl.x, pl_sd->bl.y, sat_num, 0xFFFFFF);
				flag = 0;
			}
		}
	}
	mapit_free(iter);

	if (count > 0) {
		snprintf(atcmd_output, CHAT_SIZE_MAX, "Found %d ea. Prices from %dz to %dz", count, MinPrice, MaxPrice);
		clif_displaymessage(fd, atcmd_output);
	}
	else
		clif_displaymessage(fd, "Nobody buying it now.");

	return 0;
}

when use @whobuy 607  error popoout

image.thumb.png.80340d5ef541b2b9f4a6db8b7ad64eb9.png

2 answers to this question

Recommended Posts

  • 0
Posted
On 10/22/2019 at 4:26 PM, Bringer said:

 


/*==========================================
* @whobuy - List who is buying the item (amount, price, and location).
* remake by VoidLess, original by zephyrus_cr
* re-edit by deathscythe to work in rAthena
*------------------------------------------*/
ACMD_FUNC(whobuy)
{
	char item_name[100];
	int item_id, j, count = 0, sat_num = 0;
	bool flag = 0; // place dot on the minimap?
	struct map_session_data* pl_sd;
	struct s_mapiterator* iter;
	unsigned int MinPrice = battle_config.vending_max_value, MaxPrice = 0;
	struct item_data *item_data;

	nullpo_retr(-1, sd);
	memset(item_name, '\0', sizeof(item_name));

	if (!message || !*message || sscanf(message, "%99[^\n]", item_name) < 1) {
		clif_displaymessage(fd, "Input item name or ID (use: @whobuy <name or ID>).");
		return -1;
	}
	if ((item_data = itemdb_searchname(item_name)) == NULL &&
		(item_data = itemdb_exists(atoi(item_name))) == NULL)
	{
		clif_displaymessage(fd, msg_txt(sd, 19)); // Invalid item ID or name.
		return -1;
	}

	item_id = item_data->nameid;

	iter = mapit_getallusers();
	for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter))
	{
		if (pl_sd->state.buyingstore) //check if player is autobuying
		{
			for (j = 0; j < pl_sd->buyingstore.slots; j) {
				if (pl_sd->buyingstore.items[j].nameid == item_id) {
					snprintf(atcmd_output, CHAT_SIZE_MAX, "Price %d | Amount %d | Buyer %s | Map %s[%d,%d]", pl_sd->buyingstore.items[j].price, pl_sd->buyingstore.items[j].amount, pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
					if (pl_sd->buyingstore.items[j].price < MinPrice) MinPrice = pl_sd->buyingstore.items[j].price;
					if (pl_sd->buyingstore.items[j].price > MaxPrice) MaxPrice = pl_sd->buyingstore.items[j].price;
					clif_displaymessage(fd, atcmd_output);
					count;
					flag = 1;
				}
			}
			if (flag && pl_sd->mapindex == sd->mapindex) {
				clif_viewpoint(sd, 1, 1, pl_sd->bl.x, pl_sd->bl.y, sat_num, 0xFFFFFF);
				flag = 0;
			}
		}
	}
	mapit_free(iter);

	if (count > 0) {
		snprintf(atcmd_output, CHAT_SIZE_MAX, "Found %d ea. Prices from %dz to %dz", count, MinPrice, MaxPrice);
		clif_displaymessage(fd, atcmd_output);
	}
	else
		clif_displaymessage(fd, "Nobody buying it now.");

	return 0;
}

when use @whobuy 607  error popoout

image.thumb.png.80340d5ef541b2b9f4a6db8b7ad64eb9.png

you already fixed this? *can you share with us?*

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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