unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) { if (idx == 0) { // Zeny Transfer if( amount < 0 ) return 0; if( amount > sd->status.zeny ) amount = sd->status.zeny; if( !pc_can_give_items(pc_isGM(sd)) ) amount = 0; sd->mail.zeny = amount; // clif_updatestatus(sd, SP_ZENY); return 0; } else { // Item Transfer idx -= 2; mail_removeitem(sd, 0); if( idx < 0 || idx >= MAX_INVENTORY ) return 1; if( amount < 0 || amount > sd->status.inventory[idx].amount ) return 1; if( !pc_candrop(sd, &sd->status.inventory[idx]) ) return 1; sd->mail.index = idx; sd->mail.nameid = sd->status.inventory[idx].nameid; sd->mail.amount = amount; return 0; } }
unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) { if( sd->state.secure_items ) { clif_displaymessage(sd->fd, "You can't attach. Blocked with @security"); return 1; } if( battle_config.super_woe_enable ) { clif_displaymessage(sd->fd, "Super WoE don't allow send items/zeny with attachments"); return 1; } if( idx == 0 ) { // Zeny Transfer if( amount < 0 || !pc_can_give_items(pc_isGM(sd)) ) return 1; if( amount > sd->status.zeny ) amount = sd->status.zeny; sd->mail.zeny = amount; // pc_onstatuschanged(sd, SP_ZENY); return 0; } else { // Item Transfer idx -= 2; mail_removeitem(sd, 0); if( idx < 0 || idx >= MAX_INVENTORY ) return 1; if( amount < 0 || amount > sd->status.inventory[idx].amount ) return 1; if( !pc_candrop(sd, &sd->status.inventory[idx]) ) return 1; sd->mail.index = idx; sd->mail.nameid = sd->status.inventory[idx].nameid; sd->mail.amount = amount; return 0; } }
/** [Cydh] * Gives item(s) to the player based on item group * @param sd: Player that obtains item from item group * @param group_id: The group ID of item that obtained by player * @param *group: struct s_item_group from itemgroup_db[group_id].random[idx] or itemgroup_db[group_id].must[sub_group][idx] */ static void itemdb_pc_get_itemgroup_sub(struct map_session_data *sd, struct s_item_group_entry *data) { uint16 i, get_amt = 0; struct item tmp; nullpo_retv(data); memset(&tmp, 0, sizeof(tmp)); tmp.nameid = data->nameid; tmp.bound = data->bound; tmp.identify = 1; tmp.expire_time = (data->duration) ? (unsigned int)(time(NULL) + data->duration*60) : 0; if (data->isNamed) { tmp.card[0] = itemdb_isequip(data->nameid) ? CARD0_FORGE : CARD0_CREATE; tmp.card[1] = 0; tmp.card[2] = GetWord(sd->status.char_id, 0); tmp.card[3] = GetWord(sd->status.char_id, 1); } if (!itemdb_isstackable(data->nameid)) get_amt = 1; else get_amt = data->amount; // Do loop for non-stackable item for (i = 0; i < data->amount; i += get_amt) { char flag = 0; tmp.unique_id = data->GUID ? pc_generate_unique_id(sd) : 0; // Generate GUID if ((flag = pc_additem(sd, &tmp, get_amt, LOG_TYPE_SCRIPT))) { clif_additem(sd, 0, 0, flag); if (pc_candrop(sd, &tmp)) map_addflooritem(&tmp, tmp.amount, sd->bl.m, sd->bl.x,sd->bl.y, 0, 0, 0, 0, 0); } else if (!flag && data->isAnnounced) intif_broadcast_obtain_special_item(sd, data->nameid, sd->itemid, ITEMOBTAIN_TYPE_BOXITEM); } }