Eross Posted August 9, 2021 Group: Members Topic Count: 166 Topics Per Day: 0.09 Content Count: 377 Reputation: 12 Joined: 04/05/20 Last Seen: 12 hours ago Share Posted August 9, 2021 Hi ! Im using @whosell and @whobuy on my old server .. apparently something has change since we upgraded to latest rathena ... errors are coming since then .. Please help heres my source codes Index: atcommand.c =================================================================== --- atcommand.c (revision 16082) +++ atcommand.c (working copy) @@ -8473,6 +8473,69 @@ return 0; } +/*========================================== +* @whobuys - List who is buying the item (amount, price, and location). +* remake by VoidLess, original by zephyrus_cr +* re-edit by deathscythe to work in rAthena +*------------------------------------------*/ +ACMD_FUNC(whobuys) +{ + char item_name[100]; + int item_id, j, count = 0, sat_num = 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); + memset(item_name, '\0', sizeof(item_name)); + + if (!message || !*message || sscanf(message, "%99[^\n]", item_name) < 1) { + clif_displaymessage(fd, "Input item name or ID (use: @whobuys <name or ID>)."); + return -1; + } + if ((item_data = itemdb_searchname(item_name)) == NULL && + (item_data = itemdb_exists(atoi(item_name))) == NULL) + { + clif_displaymessage(fd, msg_txt(sd, 19)); // Invalid item ID or name. + return -1; + } + + item_id = item_data->nameid; + + iter = mapit_getallusers(); + for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + { + if( pl_sd->buyer_id ) //check if player is autobuying + { + for (j = 0; j < pl_sd->buyingstore.slots; j++) { + if(pl_sd->buyingstore.items[j].nameid == item_id) { + snprintf(atcmd_output, CHAT_SIZE_MAX, "ID: %d | Price: %d z | Amount: %d | Buyer: %s | Location: %s (%d,%d)" + ,pl_sd->buyingstore.items[j].nameid + ,pl_sd->buyingstore.items[j].price + ,pl_sd->buyingstore.items[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x, pl_sd->bl.y); + if(pl_sd->buyingstore.items[j].price < MinPrice) MinPrice = pl_sd->buyingstore.items[j].price; + if(pl_sd->buyingstore.items[j].price > MaxPrice) MaxPrice = pl_sd->buyingstore.items[j].price; + clif_displaymessage(fd, atcmd_output); + count++; + flag = 1; + } + } + if(flag && pl_sd->mapindex == sd->mapindex){ + clif_viewpoint(sd, 1, 1, pl_sd->bl.x, pl_sd->bl.y, ++sat_num, 0xFFFFFF); + flag = 0; + } + } + } + mapit_free(iter); + + if(count > 0) { + snprintf(atcmd_output,CHAT_SIZE_MAX, "Found %d ea. Prices from %dz to %dz", count, MinPrice, MaxPrice); + clif_displaymessage(fd, atcmd_output); + } else + clif_displaymessage(fd, "Nobody buying it now."); + + return 0; +} + /** * Fills the reference of available commands in atcommand DBMap **/ @@ -8717,6 +8780,7 @@ ACMD_DEF(charcommands), ACMD_DEF(font), ACMD_DEF(accinfo), + ACMD_DEF(whobuys), /** * For Testing Purposes, not going to be here after we're done. **/ diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index cab676cce..b7456cda7 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -8395,6 +8395,152 @@ ACMD_FUNC(mapflag) { return 0; } +/*========================================== +* @whosells - List who is vending the item (amount, price, and location). +* ported to work in latest rA [Cookie] +*------------------------------------------*/ +ACMD_FUNC(whosells) +{ + 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: @whosells (<+refine> )(<item_id>)(<[card_id]>) or @whosells <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; + 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: @whosells (<+refine> )(<item_id>)(<[card_id]>) or @whosells <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((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(item_data->type == IT_ARMOR) + snprintf(atcmd_output, CHAT_SIZE_MAX, "Refine: +%d | ID: %d | Card: [%d] | Price: %d z | Amount: %d | Seller: %s | Location: %s (%d,%d)" + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].refine + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[0] + ,pl_sd->vending[j].value + ,pl_sd->vending[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x,pl_sd->bl.y); + else if(item_data->type == IT_WEAPON) + snprintf(atcmd_output, CHAT_SIZE_MAX, "Refine: +%d | ID: %d | Cards: [%d,%d,%d,%d] | Price: %d z | Amount: %d | Seller: %s | Location: %s (%d,%d)" + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].refine + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[0] + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[1] + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[2] + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[3] + ,pl_sd->vending[j].value + ,pl_sd->vending[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x,pl_sd->bl.y); + else + snprintf(atcmd_output, CHAT_SIZE_MAX, "ID: %d | Price: %d z | Amount: %d | Seller: %s | Location: %s (%d,%d)" + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid + ,pl_sd->vending[j].value + ,pl_sd->vending[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x, pl_sd->bl.y); + 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; + clif_displaymessage(fd, atcmd_output); + count++; + flag = 1; + } + if (flag && pl_sd->mapindex == sd->mapindex) { + //if (flag && pl_sd->bl.m == sd->bl.m) { + clif_viewpoint(sd, 1, 1, pl_sd->bl.x, pl_sd->bl.y, ++sat_num, 0xFFFFFF); + flag = 0; + } + } + } + mapit_free(iter); + if(count > 0) { + snprintf(atcmd_output, CHAT_SIZE_MAX, "Found %d ea. Prices from %dz to %dz.", count, MinPrice, MaxPrice); + clif_displaymessage(fd, atcmd_output); + } else + clif_displaymessage(fd, "Nobody is selling it now."); + return 0; +} + /*=================================== * Remove some messages *-----------------------------------*/ @@ -10593,6 +10739,7 @@ void atcommand_basecommands(void) { ACMD_DEFR(channel,ATCMD_NOSCRIPT), ACMD_DEF(fontcolor), ACMD_DEF(langtype), + ACMD_DEF(whosells), #ifdef VIP_ENABLE ACMD_DEF(vip), ACMD_DEF(showrate), whobuy_whosell.patch 1 Quote Link to comment Share on other sites More sharing options...
1 EveeX Posted July 4, 2022 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 32 Reputation: 29 Joined: 09/16/20 Last Seen: December 21, 2022 Share Posted July 4, 2022 20 hours ago, G-RO said: anyone please help Change Try this Change: item_data = itemdb_searchname(item_name) Add: item_data = item_db.searchname(item_name) 1 Quote Link to comment Share on other sites More sharing options...
1 jmsngls Posted September 19, 2022 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 46 Reputation: 2 Joined: 01/15/17 Last Seen: February 8 Share Posted September 19, 2022 got answers from nitrous last September 8. Quote Change struct item_data *itemdata to std::shared_ptr<item_data> item_data then use Quote item_db.find instead of itemdb_exists 1 Quote Link to comment Share on other sites More sharing options...
0 hikashin-rae Posted October 18, 2021 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 213 Reputation: 24 Joined: 01/14/13 Last Seen: 22 hours ago Share Posted October 18, 2021 On 8/9/2021 at 9:12 AM, Eross said: Hi ! Im using @whosell and @whobuy on my old server .. apparently something has change since we upgraded to latest rathena ... errors are coming since then .. Please help heres my source codes Index: atcommand.c =================================================================== --- atcommand.c (revision 16082) +++ atcommand.c (working copy) @@ -8473,6 +8473,69 @@ return 0; } +/*========================================== +* @whobuys - List who is buying the item (amount, price, and location). +* remake by VoidLess, original by zephyrus_cr +* re-edit by deathscythe to work in rAthena +*------------------------------------------*/ +ACMD_FUNC(whobuys) +{ + char item_name[100]; + int item_id, j, count = 0, sat_num = 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); + memset(item_name, '\0', sizeof(item_name)); + + if (!message || !*message || sscanf(message, "%99[^\n]", item_name) < 1) { + clif_displaymessage(fd, "Input item name or ID (use: @whobuys <name or ID>)."); + return -1; + } + if ((item_data = itemdb_searchname(item_name)) == NULL && + (item_data = itemdb_exists(atoi(item_name))) == NULL) + { + clif_displaymessage(fd, msg_txt(sd, 19)); // Invalid item ID or name. + return -1; + } + + item_id = item_data->nameid; + + iter = mapit_getallusers(); + for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + { + if( pl_sd->buyer_id ) //check if player is autobuying + { + for (j = 0; j < pl_sd->buyingstore.slots; j++) { + if(pl_sd->buyingstore.items[j].nameid == item_id) { + snprintf(atcmd_output, CHAT_SIZE_MAX, "ID: %d | Price: %d z | Amount: %d | Buyer: %s | Location: %s (%d,%d)" + ,pl_sd->buyingstore.items[j].nameid + ,pl_sd->buyingstore.items[j].price + ,pl_sd->buyingstore.items[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x, pl_sd->bl.y); + if(pl_sd->buyingstore.items[j].price < MinPrice) MinPrice = pl_sd->buyingstore.items[j].price; + if(pl_sd->buyingstore.items[j].price > MaxPrice) MaxPrice = pl_sd->buyingstore.items[j].price; + clif_displaymessage(fd, atcmd_output); + count++; + flag = 1; + } + } + if(flag && pl_sd->mapindex == sd->mapindex){ + clif_viewpoint(sd, 1, 1, pl_sd->bl.x, pl_sd->bl.y, ++sat_num, 0xFFFFFF); + flag = 0; + } + } + } + mapit_free(iter); + + if(count > 0) { + snprintf(atcmd_output,CHAT_SIZE_MAX, "Found %d ea. Prices from %dz to %dz", count, MinPrice, MaxPrice); + clif_displaymessage(fd, atcmd_output); + } else + clif_displaymessage(fd, "Nobody buying it now."); + + return 0; +} + /** * Fills the reference of available commands in atcommand DBMap **/ @@ -8717,6 +8780,7 @@ ACMD_DEF(charcommands), ACMD_DEF(font), ACMD_DEF(accinfo), + ACMD_DEF(whobuys), /** * For Testing Purposes, not going to be here after we're done. **/ diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index cab676cce..b7456cda7 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -8395,6 +8395,152 @@ ACMD_FUNC(mapflag) { return 0; } +/*========================================== +* @whosells - List who is vending the item (amount, price, and location). +* ported to work in latest rA [Cookie] +*------------------------------------------*/ +ACMD_FUNC(whosells) +{ + 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: @whosells (<+refine> )(<item_id>)(<[card_id]>) or @whosells <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; + 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: @whosells (<+refine> )(<item_id>)(<[card_id]>) or @whosells <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((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(item_data->type == IT_ARMOR) + snprintf(atcmd_output, CHAT_SIZE_MAX, "Refine: +%d | ID: %d | Card: [%d] | Price: %d z | Amount: %d | Seller: %s | Location: %s (%d,%d)" + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].refine + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[0] + ,pl_sd->vending[j].value + ,pl_sd->vending[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x,pl_sd->bl.y); + else if(item_data->type == IT_WEAPON) + snprintf(atcmd_output, CHAT_SIZE_MAX, "Refine: +%d | ID: %d | Cards: [%d,%d,%d,%d] | Price: %d z | Amount: %d | Seller: %s | Location: %s (%d,%d)" + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].refine + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[0] + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[1] + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[2] + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[3] + ,pl_sd->vending[j].value + ,pl_sd->vending[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x,pl_sd->bl.y); + else + snprintf(atcmd_output, CHAT_SIZE_MAX, "ID: %d | Price: %d z | Amount: %d | Seller: %s | Location: %s (%d,%d)" + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid + ,pl_sd->vending[j].value + ,pl_sd->vending[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x, pl_sd->bl.y); + 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; + clif_displaymessage(fd, atcmd_output); + count++; + flag = 1; + } + if (flag && pl_sd->mapindex == sd->mapindex) { + //if (flag && pl_sd->bl.m == sd->bl.m) { + clif_viewpoint(sd, 1, 1, pl_sd->bl.x, pl_sd->bl.y, ++sat_num, 0xFFFFFF); + flag = 0; + } + } + } + mapit_free(iter); + if(count > 0) { + snprintf(atcmd_output, CHAT_SIZE_MAX, "Found %d ea. Prices from %dz to %dz.", count, MinPrice, MaxPrice); + clif_displaymessage(fd, atcmd_output); + } else + clif_displaymessage(fd, "Nobody is selling it now."); + return 0; +} + /*=================================== * Remove some messages *-----------------------------------*/ @@ -10593,6 +10739,7 @@ void atcommand_basecommands(void) { ACMD_DEFR(channel,ATCMD_NOSCRIPT), ACMD_DEF(fontcolor), ACMD_DEF(langtype), + ACMD_DEF(whosells), #ifdef VIP_ENABLE ACMD_DEF(vip), ACMD_DEF(showrate), whobuy_whosell.patch 10.2 kB · 7 downloads I already update my whosell on git try to test it out and give me feedback thank you. https://github.com/coookie1010/Server-Patches/blob/main/rA-whosell.patch 1 Quote Link to comment Share on other sites More sharing options...
0 Eross Posted October 19, 2021 Group: Members Topic Count: 166 Topics Per Day: 0.09 Content Count: 377 Reputation: 12 Joined: 04/05/20 Last Seen: 12 hours ago Author Share Posted October 19, 2021 11 hours ago, Cookie-rae said: I already update my whosell on git try to test it out and give me feedback thank you. https://github.com/coookie1010/Server-Patches/blob/main/rA-whosell.patch H thankyou sensei ! Do you also have @whobuy ??? Thankyou Quote Link to comment Share on other sites More sharing options...
0 Onairda Posted June 10, 2022 Group: Members Topic Count: 74 Topics Per Day: 0.02 Content Count: 177 Reputation: 9 Joined: 12/30/16 Last Seen: 3 hours ago Share Posted June 10, 2022 On 8/9/2021 at 9:12 AM, Eross said: Hi ! Im using @whosell and @whobuy on my old server .. apparently something has change since we upgraded to latest rathena ... errors are coming since then .. Please help heres my source codes Index: atcommand.c =================================================================== --- atcommand.c (revision 16082) +++ atcommand.c (working copy) @@ -8473,6 +8473,69 @@ return 0; } +/*========================================== +* @whobuys - List who is buying the item (amount, price, and location). +* remake by VoidLess, original by zephyrus_cr +* re-edit by deathscythe to work in rAthena +*------------------------------------------*/ +ACMD_FUNC(whobuys) +{ + char item_name[100]; + int item_id, j, count = 0, sat_num = 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); + memset(item_name, '\0', sizeof(item_name)); + + if (!message || !*message || sscanf(message, "%99[^\n]", item_name) < 1) { + clif_displaymessage(fd, "Input item name or ID (use: @whobuys <name or ID>)."); + return -1; + } + if ((item_data = itemdb_searchname(item_name)) == NULL && + (item_data = itemdb_exists(atoi(item_name))) == NULL) + { + clif_displaymessage(fd, msg_txt(sd, 19)); // Invalid item ID or name. + return -1; + } + + item_id = item_data->nameid; + + iter = mapit_getallusers(); + for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + { + if( pl_sd->buyer_id ) //check if player is autobuying + { + for (j = 0; j < pl_sd->buyingstore.slots; j++) { + if(pl_sd->buyingstore.items[j].nameid == item_id) { + snprintf(atcmd_output, CHAT_SIZE_MAX, "ID: %d | Price: %d z | Amount: %d | Buyer: %s | Location: %s (%d,%d)" + ,pl_sd->buyingstore.items[j].nameid + ,pl_sd->buyingstore.items[j].price + ,pl_sd->buyingstore.items[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x, pl_sd->bl.y); + if(pl_sd->buyingstore.items[j].price < MinPrice) MinPrice = pl_sd->buyingstore.items[j].price; + if(pl_sd->buyingstore.items[j].price > MaxPrice) MaxPrice = pl_sd->buyingstore.items[j].price; + clif_displaymessage(fd, atcmd_output); + count++; + flag = 1; + } + } + if(flag && pl_sd->mapindex == sd->mapindex){ + clif_viewpoint(sd, 1, 1, pl_sd->bl.x, pl_sd->bl.y, ++sat_num, 0xFFFFFF); + flag = 0; + } + } + } + mapit_free(iter); + + if(count > 0) { + snprintf(atcmd_output,CHAT_SIZE_MAX, "Found %d ea. Prices from %dz to %dz", count, MinPrice, MaxPrice); + clif_displaymessage(fd, atcmd_output); + } else + clif_displaymessage(fd, "Nobody buying it now."); + + return 0; +} + /** * Fills the reference of available commands in atcommand DBMap **/ @@ -8717,6 +8780,7 @@ ACMD_DEF(charcommands), ACMD_DEF(font), ACMD_DEF(accinfo), + ACMD_DEF(whobuys), /** * For Testing Purposes, not going to be here after we're done. **/ diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index cab676cce..b7456cda7 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -8395,6 +8395,152 @@ ACMD_FUNC(mapflag) { return 0; } +/*========================================== +* @whosells - List who is vending the item (amount, price, and location). +* ported to work in latest rA [Cookie] +*------------------------------------------*/ +ACMD_FUNC(whosells) +{ + 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: @whosells (<+refine> )(<item_id>)(<[card_id]>) or @whosells <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; + 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: @whosells (<+refine> )(<item_id>)(<[card_id]>) or @whosells <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((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(item_data->type == IT_ARMOR) + snprintf(atcmd_output, CHAT_SIZE_MAX, "Refine: +%d | ID: %d | Card: [%d] | Price: %d z | Amount: %d | Seller: %s | Location: %s (%d,%d)" + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].refine + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[0] + ,pl_sd->vending[j].value + ,pl_sd->vending[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x,pl_sd->bl.y); + else if(item_data->type == IT_WEAPON) + snprintf(atcmd_output, CHAT_SIZE_MAX, "Refine: +%d | ID: %d | Cards: [%d,%d,%d,%d] | Price: %d z | Amount: %d | Seller: %s | Location: %s (%d,%d)" + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].refine + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[0] + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[1] + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[2] + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].card[3] + ,pl_sd->vending[j].value + ,pl_sd->vending[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x,pl_sd->bl.y); + else + snprintf(atcmd_output, CHAT_SIZE_MAX, "ID: %d | Price: %d z | Amount: %d | Seller: %s | Location: %s (%d,%d)" + ,pl_sd->cart.u.items_cart[pl_sd->vending[j].index].nameid + ,pl_sd->vending[j].value + ,pl_sd->vending[j].amount + ,pl_sd->status.name + ,mapindex_id2name(pl_sd->mapindex) + ,pl_sd->bl.x, pl_sd->bl.y); + 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; + clif_displaymessage(fd, atcmd_output); + count++; + flag = 1; + } + if (flag && pl_sd->mapindex == sd->mapindex) { + //if (flag && pl_sd->bl.m == sd->bl.m) { + clif_viewpoint(sd, 1, 1, pl_sd->bl.x, pl_sd->bl.y, ++sat_num, 0xFFFFFF); + flag = 0; + } + } + } + mapit_free(iter); + if(count > 0) { + snprintf(atcmd_output, CHAT_SIZE_MAX, "Found %d ea. Prices from %dz to %dz.", count, MinPrice, MaxPrice); + clif_displaymessage(fd, atcmd_output); + } else + clif_displaymessage(fd, "Nobody is selling it now."); + return 0; +} + /*=================================== * Remove some messages *-----------------------------------*/ @@ -10593,6 +10739,7 @@ void atcommand_basecommands(void) { ACMD_DEFR(channel,ATCMD_NOSCRIPT), ACMD_DEF(fontcolor), ACMD_DEF(langtype), + ACMD_DEF(whosells), #ifdef VIP_ENABLE ACMD_DEF(vip), ACMD_DEF(showrate), whobuy_whosell.patch 10.2 kB · 18 downloads Error occured on latest rAthena. please see below. thanks for your help Quote Link to comment Share on other sites More sharing options...
0 Onairda Posted July 3, 2022 Group: Members Topic Count: 74 Topics Per Day: 0.02 Content Count: 177 Reputation: 9 Joined: 12/30/16 Last Seen: 3 hours ago Share Posted July 3, 2022 anyone please help On 6/11/2022 at 12:15 AM, G-RO said: Error occured on latest rAthena. please see below. thanks for your help Quote Link to comment Share on other sites More sharing options...
0 JinYuichi Posted July 4, 2022 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 110 Reputation: 30 Joined: 11/24/14 Last Seen: April 12 Share Posted July 4, 2022 they have a git standby too, which removed itemdb_exists().. when they pass it to the root it will fail again, you also have to edit those parts https://github.com/rathena/rathena/pull/7084 Quote Link to comment Share on other sites More sharing options...
Question
Eross
Hi ! Im using @whosell and @whobuy on my old server .. apparently something has change since we upgraded to latest rathena ...
errors are coming since then .. Please help heres my source codes
whobuy_whosell.patch
Link to comment
Share on other sites
7 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.