masterzeus Posted January 21, 2022 Posted January 21, 2022 Hello! Could this code be adapted to today's rAthena? Generates an error with the line containing "itemdb_searchname"https://github.com/coookie1010/Server-Patches/blob/main/rA-jumptosell.diff Quote
0 Shakto Posted February 19, 2022 Posted February 19, 2022 /*========================================== * @jumptosell - warps to the cheapest shop. * Made by Vengence * Make it work for latest [Shakto] *------------------------------------------*/ ACMD_FUNC(jumptosell) { 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; struct map_session_data* pl_sd; struct map_session_data* pl_sd2; struct s_mapiterator* iter; unsigned int MinPrice = battle_config.vending_max_value, MaxPrice = 0; nullpo_retr(-1, sd); if (!message || !*message) { clif_displaymessage(fd, "Use: @jumptosell (<+refine> )(<item_id>)(<[card_id]>) or @jumptosell <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)){ s_type = 1; } else if (sscanf(message, "%99[^\n]", item_name) == 1){ s_type = 1; std::shared_ptr<item_data> id = item_db.searchname( item_name ); if( id == nullptr ){ clif_displaymessage(fd, "No item found with this name"); return -1; } item_id = id->nameid; } else { clif_displaymessage(fd, "Use: @jumptosell (<+refine> )(<item_id>)(<[card_id]>) or @jumptosell <name>"); return -1; } struct item_data *item_data; //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((item_data = itemdb_exists(pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid)) == NULL) continue; if(s_type & 1 && pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid != item_id) continue; if(s_type & 2 && ((item_data->type != IT_ARMOR && item_data->type != IT_WEAPON) || (pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[0] != card_id && pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[1] != card_id && pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[2] != card_id && pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[3] != card_id))) continue; if(s_type & 4 && ((item_data->type != IT_ARMOR && item_data->type != IT_WEAPON) || pl_sd->cart.u.items_cart[pl_sd->vending[j].index].refine != refine)) continue; if(pl_sd->vending[j].value < MinPrice){ MinPrice = pl_sd->vending[j].value; pl_sd2 = pl_sd; } count++; } } } mapit_free(iter); if(count > 0) { pc_setpos(sd, pl_sd2->mapindex, pl_sd2->bl.x, pl_sd2->bl.y, CLR_TELEPORT); } else clif_displaymessage(fd, "Nobody is selling it now."); return 0; } 1 1 Quote
0 masterzeus Posted February 21, 2022 Author Posted February 21, 2022 On 2/19/2022 at 2:18 PM, Shakto said: /*========================================== * @jumptosell - warps to the cheapest shop. * Made by Vengence * Make it work for latest [Shakto] *------------------------------------------*/ ACMD_FUNC(jumptosell) { 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; struct map_session_data* pl_sd; struct map_session_data* pl_sd2; struct s_mapiterator* iter; unsigned int MinPrice = battle_config.vending_max_value, MaxPrice = 0; nullpo_retr(-1, sd); if (!message || !*message) { clif_displaymessage(fd, "Use: @jumptosell (<+refine> )(<item_id>)(<[card_id]>) or @jumptosell <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)){ s_type = 1; } else if (sscanf(message, "%99[^\n]", item_name) == 1){ s_type = 1; std::shared_ptr<item_data> id = item_db.searchname( item_name ); if( id == nullptr ){ clif_displaymessage(fd, "No item found with this name"); return -1; } item_id = id->nameid; } else { clif_displaymessage(fd, "Use: @jumptosell (<+refine> )(<item_id>)(<[card_id]>) or @jumptosell <name>"); return -1; } struct item_data *item_data; //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((item_data = itemdb_exists(pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid)) == NULL) continue; if(s_type & 1 && pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid != item_id) continue; if(s_type & 2 && ((item_data->type != IT_ARMOR && item_data->type != IT_WEAPON) || (pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[0] != card_id && pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[1] != card_id && pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[2] != card_id && pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[3] != card_id))) continue; if(s_type & 4 && ((item_data->type != IT_ARMOR && item_data->type != IT_WEAPON) || pl_sd->cart.u.items_cart[pl_sd->vending[j].index].refine != refine)) continue; if(pl_sd->vending[j].value < MinPrice){ MinPrice = pl_sd->vending[j].value; pl_sd2 = pl_sd; } count++; } } } mapit_free(iter); if(count > 0) { pc_setpos(sd, pl_sd2->mapindex, pl_sd2->bl.x, pl_sd2->bl.y, CLR_TELEPORT); } else clif_displaymessage(fd, "Nobody is selling it now."); return 0; } Works fine Thanks Quote
0 Melk3000 Posted June 5, 2022 Posted June 5, 2022 (edited) Crash mapserver when i do @jumptosell, y char is vending a item with cost of 1 Billon zeny Edited June 5, 2022 by Melk3000 Quote
Question
masterzeus
Hello! Could this code be adapted to today's rAthena?
Generates an error with the line containing "itemdb_searchname"
https://github.com/coookie1010/Server-Patches/blob/main/rA-jumptosell.diff
3 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.