viewing paste Unknown #6068 | 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
BUILDIN_FUNC(getguildstorageitem){
    struct script_data *data;
    struct item_data * item_data;
    struct item item_tmp;
    int x, amount;
    TBL_PC * sd;
    struct guild_storage *gstor;
 
    data= script_getdata(st,2);
    amount = script_getnum(st,3);
    sd = ((script_hasdata(st,4)) ? map_nick2sd(script_getstr(st,4)) : script_rid2sd(st));
 
    if(sd->guild == NULL) return -1; //player have no guild
    gstor = guild2storage(sd->guild->guild_id);
 
    item_data = script_data2nameid(st,data);
    if(item_data != NULL && sd != NULL){
        if(amount <= 0 || (!itemdb_isstackable2(item_data) && amount > 10) || (itemdb_isstackable2(item_data) && amount > MAX_AMOUNT))
            amount = 1;
        memset(&item_tmp,0,sizeof(item_tmp));
        item_tmp.nameid = item_data->nameid;
        item_tmp.identify = 1;
        if(!itemdb_isstackable2(item_data) && amount > 1){
            for(x = 0; x < amount; x++)
                guild_storage_additem(sd,gstor,&item_tmp,amount);
        }else {
            guild_storage_additem(sd,gstor,&item_tmp,amount);
        }
        storage_guild_storageclose(sd);
        gstorage->lock = 0;
        log_pick_pc(sd, LOG_TYPE_NPC, amount, &item_tmp);
    }
    return 0;
}
Viewed 1317 times, submitted by lighta.