int atcommand_whosell(const int fd, struct map_session_data* sd, const char* command, const char* message)
{
unsigned char ielement[5][7] = {"", "Ice ", "Earth ", "Fire ", "Wind "};
unsigned char istarcrumb[4][7] = {"", "VS ", "VVS ", "VVVS "};
struct map_session_data *pl_sd;
char item_name[100], output[255];
int item_id, map_id = 0, j, count = 0, i = 0, mSlot = 0;
unsigned int MinPrize = battle_config.vending_max_value, MaxPrize = 0;
struct item_data *item_data;
#ifdef whosell_with_cards_name
struct item_data *item_temp;
#endif
struct s_mapiterator* iter;
memset(item_name, '0', sizeof(item_name));
memset(output, '0', sizeof(output));
if (!message || !*message || sscanf(message, "%99[^\n]", item_name) < 1) {
clif_displaymessage(fd, "Please, enter the item's name or ID (usage: @whosell <item_name> or <item_id>).");
return -1;
}
if ((item_data = itemdb_searchname(item_name)) == NULL &&
(item_data = itemdb_exists(atoi(item_name))) == NULL)
{
clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
return -1;
}
item_id = item_data->nameid;
map_id = sd->bl.m; // Required for clif_viewpoint
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if (pl_sd->vender_id) {
for (j = 0; j < pl_sd->vend_num; j++) {
if (pl_sd->status.cart[pl_sd->vending[j].index].nameid == item_id) {
// Item Found, updating Min and Max
if (pl_sd->vending[j].value < MinPrize)
MinPrize = pl_sd->vending[j].value;
if (pl_sd->vending[j].value > MaxPrize)
MaxPrize = pl_sd->vending[j].value;
if (pl_sd->bl.m == map_id)
clif_viewpoint(sd, 1, 1, pl_sd->bl.x, pl_sd->bl.y, count, 0xFFFFFF);
sprintf(output, "Vendor's Name: %s | Amount: %d | Price: %d | Location: %s(%d,%d)", pl_sd->status.name, pl_sd->vending[j].amount, pl_sd->vending[j].value, map[pl_sd->bl.m].name, pl_sd->bl.x, pl_sd->bl.y);
clif_displaymessage(fd, output);
if (item_data->type == IT_ARMOR || item_data->type == IT_WEAPON) {
i = sprintf(output, " - ");
if (pl_sd->status.cart[pl_sd->vending[j].index].refine)
i += sprintf(output+i, "+%d ", pl_sd->status.cart[pl_sd->vending[j].index].refine);
// View Element and Star Crumb only for Forge or Create Item
if (pl_sd->status.cart[pl_sd->vending[j].index].card[0] == CARD0_FORGE || pl_sd->status.cart[pl_sd->vending[j].index].card[0] == CARD0_CREATE)
i += sprintf(output+i, "%s%s", istarcrumb[(pl_sd->status.cart[pl_sd->vending[j].index].card[1] >> 8)/5], ielement[GetByte(pl_sd->status.cart[pl_sd->vending[j].index].card[1], 0)]);
// Add jName of Item to Display
i += sprintf(output+i, "%s", item_data->jname);
// View number of slots
if (item_data->slot) {
i += sprintf(output+i, "[%d] ", item_data->slot);
#ifdef whosell_with_cards_name
clif_displaymessage(fd, output);
i = sprintf(output, " - Cards: ");
#endif
for (mSlot = 0; mSlot < item_data->slot; mSlot++) {
#ifdef whosell_with_cards_name
if ((item_temp = itemdb_exists(pl_sd->status.cart[pl_sd->vending[j].index].card[mSlot])) != NULL)
i += sprintf(output+i, "[%s] ", item_temp->jname);
#else
if (pl_sd->status.cart[pl_sd->vending[j].index].card[mSlot])
i += sprintf(output+i, "[%d] ", pl_sd->status.cart[pl_sd->vending[j].index].card[mSlot]);
#endif
}
#ifdef whosell_with_cards_name
if (i>14)
#endif
clif_displaymessage(fd, output);
} else
clif_displaymessage(fd, output);
}
count++;
}
}
}
}
if(count > 0) {
sprintf(output, "Found %d being vended. Range of prices: %d ~ %d.", count, MinPrize, MaxPrize);
clif_displaymessage(fd, output);
} else
clif_displaymessage(fd, "Item not found.");
return 0;
}
Hi Guys! i have a problem in @whosell command, when i try to vend in other maps like, my custom map. when i try to use @whosell ( item_id), it doesn't searching the item. but when i vend in prontera, the @whosell is working..
i want to make this command working in other maps, not only in prontera. Thank you