Автор: ZzAQ: Дата: 06.12.2008
ACMD_FUNC(whosell);
{ AtCommand_Whosell, "@whosell", 0, atcommand_whosell },
/*==========================================
* @whosell, by zephyrus_cr. Optimized to search every maps by Amano Ginji
*------------------------------------------
*/
int atcommand_whosell(const int fd, struct map_session_data* sd, const char* command, const char* message)
{
struct map_session_data *pl_sd, **pl_allsd;
char item_name[100], output[255];
int item_id, map_id = 0, users, i, j, count = 0;
unsigned int MinPrize = battle_config.vending_max_value, MaxPrize = 0;
struct item_data *item_data;
memset(item_name, '\', sizeof(item_name));
memset(output, '\', 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 or ).");
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
pl_allsd = map_getallusers(&users); // All Player List
for (i = 0; i < users; i++) {
if ((pl_sd = pl_allsd) && (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, "Vender: %s | Amount: %d | Price: %d | Map: %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);
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;
}
AtCommand_Whosell,
Автор: : Дата: 01.01.1970