Jump to content
  • 0

Question

Posted (edited)

Hello Mam/Sir i would like to ask a help in @whosell Script im Getting this error


heres the Script :

/*==========================================
 * @whosell command
 *------------------------------------------*/
ACMD_FUNC(whosell)
{
    struct map_session_data *pl_sd, *b_sd[MAX_SEARCH];
    struct s_mapiterator* iter;

    struct item_data *item_array[MAX_SEARCH];
    int total[MAX_SEARCH], amount[MAX_SEARCH];
    unsigned int MinPrice[MAX_SEARCH], MaxPrice[MAX_SEARCH];
    char output[256];
    int i, j, count = 1;
    char item_name[100];
    int minprice = 0;

    if (!message || !*message || (
        sscanf(message, "\"%99[^\"]\" %11d", item_name, &minprice) < 1
        && sscanf(message, "%99s %11d", item_name, &minprice) < 1)
        )
    {
        clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whosell <item name or ID> {<min price>}).");
        return -1;
    }

    if ((item_array[0] = itemdb_searchname(item_name)) == NULL &&
        (item_array[0] = itemdb_exists(atoi(item_name))) == NULL)
        count = itemdb_searchname_array(item_array, MAX_SEARCH, message);

    if (count < 1)
    { // No items found
        clif_displaymessage(fd, msg_txt(sd,19));
        return -1;
    }

    if (count > MAX_SEARCH) count = MAX_SEARCH;

    // Preparing Search Recorders
    for (i = 0; i < MAX_SEARCH; i++)
    {
        total = amount = MaxPrice = 0;
        MinPrice = battle_config.vending_max_value + 1;
        b_sd = NULL;
    }

    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) continue;
        for (i = 0; i < pl_sd->vend_num; i++)
        { // Searching in the Vending List
            for (j = 0; j < count; j++)
            { // Compares with each search result
                if (pl_sd->status.cart[pl_sd->vending.index].nameid != item_array[j]->nameid)
                    continue;
                if (pl_sd->vending.value < minprice)
                    continue;

                amount[j] += pl_sd->vending.amount;
                total[j]++;

                if (pl_sd->vending.value < MinPrice[j])
                { // Best Price
                    MinPrice[j] = pl_sd->vending.value;
                    b_sd[j] = pl_sd;
                }
                if (pl_sd->vending.value > MaxPrice[j])
                    MaxPrice[j] = pl_sd->vending.value;
            }
        }
    }
    mapit_free(iter);

    for (i = 0; i < count; i++)
    {
        if (total > 0 && b_sd != NULL)
        {
            sprintf(output, "[%d] The best price found for '%s' is %u sold by '%s' at %s <%d,%d>. Max Price %u. Item found in %d shops, %d pieces for sale.", item_array->nameid, item_array->jname, MinPrice, b_sd->status.name, map[b_sd->bl.m].name, b_sd->bl.x, b_sd->bl.y, MaxPrice, total, amount);
            if (sd->bl.m == b_sd->bl.m)
                clif_viewpoint(sd, 1, 1, b_sd->bl.x, b_sd->bl.y, i, 0xFFFFFF);
        }
        else
            sprintf(output, "[%d] '%s' is not being sold at the moment...", item_array->nameid, item_array->jname);

        clif_displaymessage(sd->fd, output);
    }

    return 0;
}

 

image.thumb.png.294df7895964858954051a60570bb205.png

Edited by Mael
Use codebox

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

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.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.