viewing paste Unknown #15101 | C

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
ACMD(itemmap) {
    char item_name[100], party_name[NAME_LENGTH], guild_name[NAME_LENGTH];
    int amount, get_type = 0, get_count, i, map;
    struct item it;
    struct item_data *item_data;
    struct party_data *p;
    struct guild *g;
    struct s_mapiterator *iter = NULL;
    struct map_session_data *pl_sd = NULL;
 
    if (!sd) return false;
    
    memset(item_name, '\0', sizeof(item_name));
    memset(party_name, '\0', sizeof(party_name));
    memset(guild_name, '\0', sizeof(guild_name));
 
    if (strstr(command, "1") != NULL)
        get_type = 1;
    else if (strstr(command, "2") != NULL)
        get_type = 2;
 
    if (!message || !*message || (
        get_type == 0 && sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 1 
                      && sscanf(message, "%99s %d", item_name, &amount) < 1 )
    ) {
        clif->message(fd, "Please, enter an item name/id (usage: @itemmap <item name or ID> {amount}).");
        return false;
    }
    if ( get_type == 1 && sscanf(message, "\"%99[^\"]\" %d, %23[^\n]", item_name, &amount, party_name) < 2 
                       && sscanf(message, "%99s %d, %23[^\n]", item_name, &amount, party_name) < 2 )
    {
        clif->message(fd, "Please, enter an item name/id (usage: @itemmap1 <item id/name> <amount>, <party name>).");
        return false;
    }
    if ( get_type == 2 && sscanf(message, "\"%99[^\"]\" %d, %23[^\n]", item_name, &amount, guild_name) < 2 
                       && sscanf(message, "%99s %d, %23[^\n]", item_name, &amount, guild_name) < 2 )
    {
        clif->message(fd, "Please, enter an item name/id (usage: @itemmap2 <item id/name> <amount>, <guild name>).");
        return false;
    }
    if ((item_data = itemdb->search_name(item_name)) == NULL &&
        (item_data = itemdb->exists(atoi(item_name))) == NULL)
    {
        clif->message(fd,"Invalid item ID or name."); // Invalid item ID or name.
        return false;
    }
    memset(&it, 0, sizeof(it));
    it.nameid = item_data->nameid;
    if (amount <= 0)
        amount = 1;
    //Check if it's stackable.
    if (!itemdb->isstackable2(item_data))
        get_count = 1;
    else
        get_count = amount;
    
    it.identify = 1;
    
    map = sd->bl.m;
    
    switch(get_type)
    {
        case 1:
            if( (p = party->searchname(party_name)) == NULL )
            {
                clif->message(fd,"Incorrect name/ID, or no one from the specified party is online."); // Incorrect name or ID, or no one from the party is online.
                return false;
            }
            for( i=0; i < MAX_PARTY; i++ )
                if( p->data[i].sd && map == p->data[i].sd->bl.m )
                    pc_getitem_map(p->data[i].sd,it,amount,get_count,LOG_TYPE_COMMAND);
            break;
        case 2:
            if( (g = guild->searchname(guild_name)) == NULL )
            {
                clif->message(fd,"Incorrect name/ID, or no one from the specified guild is online."); // Incorrect name/ID, or no one from the guild is online.
                return false;
            }
            for( i=0; i < g->max_member; i++ )
                if( g->member[i].sd && map == g->member[i].sd->bl.m )
    >>>>> ERROR pc_getitem_map              pc_getitem_map(g->member[i].sd,it,amount,get_count,LOG_TYPE_COMMAND);
            break;
        case 3:
            iter = mapit_getallusers();
            for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) {
                if( map != pl_sd->bl.m )
                    continue;
                pc_getitem_map(pl_sd,it,amount,get_count,LOG_TYPE_COMMAND);
            }
            mapit->free(iter);
            break;
    }
 
    clif->message(fd,"Item created"); // Item created.
    return true;
 
 
    clif->message(fd,"Item created"); // Item created.
    return true;
}
Viewed 676 times, submitted by neil413.