Jump to content
  • 0

Help in @whosell


Limestone

Question


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

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

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

did you include your custom map in the 'maps_athena.conf' ???

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

yes.. i already do that, but still the @whosell command not working. i think its in the src code. but i dont know where.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

this code is that one that gets all characters and check its location..

  iter = mapit_getallusers();
  for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )

BTW is this command only searches vendors with in the same map of the user that uses the command??

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

hmm no. even if im in izlude, then one merchant vended apple in prontera, when i use @whosell apple. it works. but in other map, the command is not working, it says Item not found.

Edited by Rage
Link to comment
Share on other sites

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...