viewing paste Unknown #5924 | C

Posted on the
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
ACMD_FUNC(item)
{
    char item_name[100];
    int number = 0, item_id, flag, bound = 0;
    struct item item_tmp;
    struct item_data *item_data;
    int get_count, i;
    nullpo_retr(-1, sd);
 
    memset(item_name, '\0', sizeof(item_name));
 
    if (!message || !*message || (
        sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
        sscanf(message, "%99s %d", item_name, &number) < 1
    )) {
        clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
        return -1;
    }
 
    if (number <= 0)
        number = 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;
    }
 
    if( !strcmpi(command+1,"bounditem") )
        bound = 1;
 
    item_id = item_data->nameid;
    get_count = number;
    //Check if it's stackable.
    if( !itemdb_isstackable2(item_data) )
    {
        if( bound && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) )
        {
            clif_displaymessage(fd, "Cannot create bounded pet eggs or pet armors.");
            return -1;
        }
        get_count = 1;
    }
    else if( bound )
    {
        clif_displaymessage(fd, "Cannot create bounded stackable items.");
        return -1;
    }
 
    if(item_data->flag.trade_restriction&99){
        if(sd->status.account_id != 2000002) //we could move that id in battle conf
            return -1;
    }
 
    for( i = 0; i < number; i += get_count )
    {
        // if not pet egg
        if( !pet_create_egg(sd, item_id) )
        {
            memset(&item_tmp, 0, sizeof(item_tmp));
            item_tmp.nameid = item_id;
            item_tmp.identify = 1;
            item_tmp.bound = bound;
 
            if( (flag = pc_additem(sd, &item_tmp, get_count)) )
                clif_additem(sd, 0, 0, flag);
        }
 
        //Logs (A)dmins items [Lupus]
        if( log_config.enable_logs&0x400 )
            log_pick_pc(sd, "A", item_id, get_count, NULL, item_tmp.serial);
 
        item_tmp.serial = 0;
    }
 
    clif_displaymessage(fd, msg_txt(18)); // Item created.
    return 0;
}
Viewed 1574 times, submitted by lighta.