Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h> // für atoi()
- #include "../common/HPMi.h"
- #include "../map/script.h"
- #include "../map/pc.h"
- #include "../map/map.h"
- #include "../map/itemdb.h"
- #include "../map/buyingstore.h"
- #include "../map/battle.h"
- #include "../map/atcommand.h"
- #include "../common/mapindex.h"
- #include "../common/nullpo.h" // für nullpo_retr
- #include "../common/HPMDataCheck.h"
- // um funktions fehler zu beheben beim compilieren der plugins man atoi machen , oder nen anderen func namen
- HPExport struct hplugin_info pinfo = {
- "whobuy", // Plugin name
- SERVER_TYPE_MAP,// Which server types this plugin works with?
- "1.0", // Plugin version
- HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
- };
- ACMD(whobuy)
- {
- char item_name[100];
- char atcmd_output[255+1];
- int item_id, j, count = 0, sat_num = 0;
- bool flag = 0;
- struct map_session_data* pl_sd;
- struct s_mapiterator* iter;
- int MinPrice = 999999999, MaxPrice = 0;
- struct item_data *item_data;
- if (!message || !*message || sscanf(message, "%99[^\n]", item_name) < 1)
- {
- clif->message(fd, "Input item name or ID (use: @whobuy <name or ID>).");
- return false;
- }
- if ((item_data = itemdb->search_name(item_name)) == NULL &&
- (item_data = itemdb->exists(atoi(item_name))) == NULL)
- {
- clif->message(fd, msg_txt(19)); // Invalid item ID or name.
- return false;
- }
- 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->state.buyingstore)//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, "Price %d | Amount %d | Buyer %s | Map %s[%d,%d]",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->message(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->message(fd, atcmd_output);
- } else
- clif->message(fd, "Nobody buying it now.");
- return true;
- }
- /* Server Startup */
- HPExport void plugin_init (void)
- {
- clif = GET_SYMBOL("clif");
- script = GET_SYMBOL("script");
- battle = GET_SYMBOL("battle");
- mapit = GET_SYMBOL("mapit");
- map = GET_SYMBOL("map");
- itemdb = GET_SYMBOL("itemdb");
- buyingstore = GET_SYMBOL("buyingstore");
- atcommand = GET_SYMBOL("atcommand");
- mapindex = GET_SYMBOL("mapindex");
- addAtcommand("whobuy",whobuy);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement