Перейти к содержанию

[SRC] @whobuy [Item_id]


Qunis

Рекомендуемые сообщения

- src\map\atcommand.c

/*==========================================
* @whobuy [Item_ID]
*==========================================*/
int atcommand_whobuy(const int fd, struct map_session_data* sd, const char* command, const char* message)
{
char item_name[100];
int item_id, j, count = 0, sat_num = 0;
bool flag = 0;
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, "Использовать: @whobuy [Item_Name] или [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));
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->autobuy_num )
{
for (j = 0; j < pl_sd->autobuy_num; j++) {
if(pl_sd->autobuy[j].id == item_id) {
snprintf(atcmd_output, CHAT_SIZE_MAX, "Покупатель: %s | Количество: %d | Цена: %d | Локация: %s(%d,%d)",pl_sd->status.name,pl_sd->autobuy[j].amount,pl_sd->autobuy[j].price,mapindex_id2name(pl_sd->mapindex),pl_sd->bl.x, pl_sd->bl.y);
if(pl_sd->autobuy[j].price < MinPrice) MinPrice = pl_sd->autobuy[j].price;
if(pl_sd->autobuy[j].price > MaxPrice) MaxPrice = pl_sd->autobuy[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, "Найдено покупателей: %d. Цены: %dz ~ %dz.", count, MinPrice, MaxPrice);
clif_displaymessage(fd, atcmd_output);
} else
clif_displaymessage(fd, "Предмет не покупают.");

return 0;
}

{"whobuy",            1,1, atcommand_whobuy },

- conf\atcommand_athena.conf

whobuy: 0,40

  • Upvote 2
Ссылка на комментарий
Поделиться на другие сайты

  • 4 года спустя...
×
×
  • Создать...
Яндекс.Метрика