This is a script I'd made that's similar to what you want, where only a set number of non-stackable items are destroyed. The "FOOD" tag would need to be changed to what you want removed, and the name likely to something more appropriate, but it should work for you despite being simplistic.
Called from the main routine, oPC is the character, nCount is how many to destroy.
void RemoveFood (object oPC, int nCount)
{
int nCounter = 1;
object oItem = GetFirstItemInInventory (oPC);
while (GetIsObjectValid (oItem) && nCounter <= nCount)
{
if (GetTag (oItem) == "FOOD")
{
DestroyObject (oItem, 0.5);
nCounter ++;
}
oItem = GetNextItemInInventory(oPC);
}
}
Edit: Note that, this script, being simple, doesn't check inside containers. That can be done with a little tweaking if you'd need that aspect of it.
Modifié par Failed.Bard, 16 août 2011 - 06:37 .