Jump to content

[Release] @command Jump To Who Sell


Vengeance

Recommended Posts


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  65
  • Reputation:   13
  • Joined:  01/08/12
  • Last Seen:  

Jump To Who Sell

This command searches for the cheapest seller and warps to him..

/*==========================================
* @jumptowhosell - warps to the cheapest shop.
* Made by Vengence
*------------------------------------------*/
ACMD_FUNC(jumptowhosell)
{
char item_name[100];
int item_id = 0, j, count = 0, sat_num = 0;
int s_type = 1; // search bitmask: 0-name,1-id, 2-card, 4-refine
int refine = 0,card_id = 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);

if (!message || !*message) {
clif_displaymessage(fd, "Use: @jtws (<+refine> )(<item_id>)(<[card_id]>) or @jtws <name>");
return -1;
}

if (sscanf(message, "+%d %d[%d]", &refine, &item_id, &card_id) == 3){
s_type = 1+2+4;
}
else if (sscanf(message, "+%d %d", &refine, &item_id) == 2){
s_type = 1+4;
}
else if (sscanf(message, "+%d [%d]", &refine, &card_id) == 2){
s_type = 2+4;
}
else if (sscanf(message, "%d[%d]", &item_id, &card_id) == 2){
s_type = 1+2;
}
else if (sscanf(message, "[%d]", &card_id) == 1){
s_type = 2;
}
else if (sscanf(message, "+%d", &refine) == 1){
s_type = 4;
}
else if (sscanf(message, "%d", &item_id) == 1 && item_id == atoi(message)){
//names, that start on num are not working
//so implemented minumum item_id>500
//or better make item_id == atoi(message) ?
s_type = 1;
}
else if (sscanf(message, "%99[^\n]", item_name) == 1){
s_type = 1;
if ((item_data = itemdb_searchname(item_name)) == NULL){
clif_displaymessage(fd, "Not found item with this name");
return -1;
}
item_id = item_data->nameid;
}
else {
clif_displaymessage(fd, "Use: @jtws (<+refine> )(<item_id>)(<[card_id]>) or @jtws <name>");
return -1;
}


//check card
if(s_type & 2 && ((item_data = itemdb_exists(card_id)) == NULL || item_data->type != IT_CARD)){
clif_displaymessage(fd, "Not found a card with than ID");
return -1;
}
//check item
if(s_type & 1 && (item_data = itemdb_exists(item_id)) == NULL){
clif_displaymessage(fd, "Not found an item with than ID");
return -1;
}
//check refine
if(s_type & 4){
if (refine<0 || refine>10){
clif_displaymessage(fd, "Refine out of bounds: 0 - 10");
return -1;
}
/*if(item_data->type != IT_WEAPON && item_data->type != IT_ARMOR){
clif_displaymessage(fd, "Use refine only with weapon or armor");
return -1;
}*/
}

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 ) //check if player is vending
{
for (j = 0; j < pl_sd->vend_num; j++) {
if(pl_sd->vending[j].value < MinPrice) MinPrice = pl_sd->vending[j].value;
if(pl_sd->vending[j].value > MaxPrice) MaxPrice = pl_sd->vending[j].value;
count++;
flag = 1;
}
if(flag && pl_sd->mapindex == sd->mapindex){
flag = 0;
}
}
}
mapit_free(iter);

if(count > 0) {
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 ) //check if player is vending
{
for (j = 0; j < pl_sd->vend_num; j++) {
if(pl_sd->vending[j].value == MinPrice)
{
pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
snprintf(atcmd_output,CHAT_SIZE_MAX, "Warped to %s", pl_sd->status.name);
clif_displaymessage(fd, atcmd_output);
}
}
}
}
} else
clif_displaymessage(fd, "Nobody is selling it now.");

return 0;
}

and search for in atcommand.c

 { "font",    1,1,   atcommand_font },

and below it add

 { "jtws",    1,99,  atcommand_jumptowhosell }, //[Vengence]

This is just a modification of the whosell command so the credit also goes to the creator of the whosell command.

command_jtws.patch

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  61
  • Reputation:   6
  • Joined:  12/23/11
  • Last Seen:  

Thanks this command is nice!!

Link to comment
Share on other sites

  • 6 years later...

  • Group:  Members
  • Topic Count:  56
  • Topics Per Day:  0.01
  • Content Count:  224
  • Reputation:   4
  • Joined:  02/09/12
  • Last Seen:  

pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);

Got this problem ON latest git

Severity    Code    Description    Project    File    Line    Suppression State
Error    C2664    'e_setpos pc_setpos(map_session_data *,unsigned short,int,int,clr_type)': cannot convert argument 5 from 'int' to 'clr_type'    map-server    c:\users\jhay tech\desktop\rathena\src\custom\atcommand.inc    114    
 

 

Edited by simplexjay2
Link to comment
Share on other sites

  • 2 years later...

  • Group:  Members
  • Topic Count:  253
  • Topics Per Day:  0.06
  • Content Count:  701
  • Reputation:   16
  • Joined:  01/07/12
  • Last Seen:  

sorry for noob question, how to install this to my server?

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
Reply to this topic...

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