BUILDIN_FUNC(checkweight2) { int nameid=-1, amount=-1, nbitems=0, weight=0; int i=0, amount2=0, slots=0; struct item_data* id = NULL; TBL_PC *sd = script_rid2sd(st); nullpo_retr(1,sd); nbitems = script_lastdata(st); if(nbitems%2){ ShowError("buildin_checkweight2: Invalid nbitem='%d', must be a multiple of 2.\n", nbitems); script_pushint(st,0); return 1; } slots = pc_inventoryblank(sd); for(i=2; iweight > sd->max_weight ) {// too heavy script_pushint(st,0); return 0; } switch( pc_checkadditem(sd, nameid, amount) ) { case ADDITEM_EXIST: // item is already in inventory, but there is still space for the requested amount break; case ADDITEM_NEW: if( itemdb_isstackable(nameid) ) {// stackable amount2++; if( slots < amount2 ){ script_pushint(st,0); return 0; } } else {// non-stackable amount2 += amount; //amount of new non stackables if( slots < amount2 ){ //do we still have enough place in inventory for them script_pushint(st,0); return 0; } } break; case ADDITEM_OVERAMOUNT: script_pushint(st,0); return 0; } } script_pushint(st,1); return 0; }