You can bypass this by selecting the next inventory item and then directly afterwards select the previous. Just add the lines
$player1.getNextInvItem();
$player1.getPrevInvItem();
to the code. Regarding the loot type you pay with, you could just substract it partly over the types.
float cost=50;
float paid;
if ($player1.getLootAmount(LOOT_TOTAL>=50) {
for (int i=1;i<4;i++) {
paid=min($player1.getLootAmount(i),cost);
cost-=paid;
$player1.changeLootAmount(i,-paid);
}
}
This assumes that the loot types are numbered from 1 to 3. Maybe it's 0 to 2, dunno. Btw, why is there a do-while-loop? Anyways, the changed script would look like this
void getbroadhead() {
if (player1.getLootAmount(LOOT_TOTAL)>=50) {
float cost=50; float paid;
for (int i=1;i<4;i++) {
paid=min($player1.getLootAmount(i),cost);
cost-=paid;
$player1.changeLootAmount(i,-paid);
}
$player1.getNextInvItem();
$player1.getPrevInvItem();
sys.cacheSoundShader ("frob_loot");
entity broadhead1 = sys.spawn("atdm:ammo_broadhead");
$player1.addInvItem(broadhead1);
}
}
The function min returns the minimum of two values. Don't know if there is a implementation for it already, but it should look like this
float min(float a,float {
if (a< return a;
return B;
}
F****ng forum always saves the b as capital letter, so don't worry.