void oRemove (object oThingie, string oThing, int oDismany) 
{ 

object oItem = GetItemPossessedBy(oThingie, oThing); 
int nSize = GetItemStackSize(oItem); 

while (oDismany && IsValidObject(oItem)){

if (GetTag(oItem)==oThing){

if (nSize==1){ 
DestroyObject(oItem); 
oDismany--; 
} 
 
if (oDismany>=nSize && nSize>=2){
DestroyObject(oItem);
oDismany=oDismany-nSize;
}

if(oDismany<nSize && nSize >= 2){ 
int nNewSize = (nSize - oDismany); 
SetItemStackSize(oItem,nNewSize); 
oDismany==0;
} 

} 

oItem = GetNextItemInInventory(oThingie);
nSize = GetItemStackSize(oItem);
}
}