Scripts like ga_take_item or ga_destroy_item are notoriously bugged where stacked items are concerned. They tend to treat the entire stack as one item.
I've been using a corrected version of ga_destroy_item for years, which I think I saw posted on the old forums. It has an additional loop that deals with stacks. I use it in conjunction with CopyItem(), recreating the item in the new inventory and destroying it in the old.
// ga_destroy_item2
/*
This takes an item from a player
sItemTag = This is the string name of the item's tag
nQuantity = The number of items to destroy. -1 is all of the Player's items of that tag.
*/
#include "nw_i0_plot"
void DestroyItems(object oTarget,string sItem,int nNumItems)
{
int nCount = 0;
object oItem = GetFirstItemInInventory(oTarget);
while (GetIsObjectValid(oItem) == TRUE && nCount < nNumItems)
{
if (GetTag(oItem) == sItem)
{
int nRemainingToDestroy = nNumItems - nCount;
int nStackSize = GetItemStackSize(oItem);
if(nStackSize <= nRemainingToDestroy)
{
DestroyObject(oItem,0.1f);
nCount += nStackSize;
}
else
{
int nNewStackSize = nStackSize - nRemainingToDestroy;
SetItemStackSize(oItem, nNewStackSize);
break;
}
}
oItem = GetNextItemInInventory(oTarget);
}
return;
}
void main(string sItemTag,int nQuantity)
{
int nTotalItem;
object oPC = GetPCSpeaker();
object oItem; // Items in inventory
if ( nQuantity < 0 ) // Destroy all instances of the item
{
nTotalItem = GetNumItems( oPC,sItemTag );
DestroyItems( oPC,sItemTag,nTotalItem );
}
else
{
DestroyItems( oPC,sItemTag,nQuantity );
}
}