aiListIndex = (BagOfHoldingSortApparelAllFLST.GetSize() - 1) ; This is a FormList of FormLists While (aiListIndex > -1) akCurrentList = BagOfHoldingSortWeaponsAllFLST.GetAt(aiListIndex) As FormList If PlayerREF.GetItemCount(akCurrentList) If PlayerREF.IsEquipped(akCurrentList) aiListIndex = (akCurrentList.GetSize() - 1) While (aiListIndex > -1) akCurrentForm = akCurrentList.GetAt(aiListIndex) As Armor If PlayerREF.IsEquipped(akCurrentForm) PlayerREF.RemoveItem(akCurrentForm, PlayerREF.GetItemCount(akCurrentForm) - 1, True, Self) Else PlayerREF.RemoveItem(akCurrentForm, PlayerREF.GetItemCount(akCurrentForm), True, Self) EndIf If PlayerREF.GetItemCount(akCurrentList) aiListIndex -= 1 Else aiListIndex = -1 EndIf EndWhile aiListIndex -= 1 Else PlayerREF.RemoveItem(akCurrentList, PlayerREF.GetItemCount(akCurrentList), True, Self) aiListIndex -= 1 EndIf Else aiListIndex -= 1 EndIf EndWhile
int n = 0 item = theNPC.GetNthForm(n) while item count = theNPC.GetItemCount(item) if count > 0 and !theNPC.isEquipped(item) theNPC.RemoveItem(item, count, true, thePlayer) else n += 1 endif item = theNPC.GetNthForm(n) endwhileThe GetNthForm function returns None when you get to the end of the list, so you don't actually need to call GetNumItems in this case.
Scriptname PilferingScript extends activemagiceffect GlobalVariable Property PilferGlobal autoObjectReference Property Imaginary autoActor Property PlayerREF autoevent OnEffectStart(Actor Target, Actor Caster) int n = 0 Form item = Target.GetNthForm(n) while itemitem = Target.GetNthForm(n)float Weight = item.GetWeight()if Weight==0.0Weight = 0.0001endIfint count = Target.GetItemCount(item) if ((item.GetGoldValue() / Weight) >= (PilferGlobal.GetValue() as float)) Target.RemoveItem(item, count, true, PlayerREF) endif n += 1item = Target.GetNthForm(n) endwhileTarget.SetActorValue("Infamy", 47)endEventScriptName PilferingScript extends ActiveMagicEffect Float fWeightInt iIndexForm kItemActor Property PlayerREF AutoGlobalVariable Property PilferGlobal AutoObjectReference Property Imaginary AutoEvent OnEffectStart(Actor akTarget, Actor akCaster) If akTarget.GetActorValue("Infamy") != 47 akTarget.SetActorValue("Infamy", 47) iIndex = akTarget.GetNumItems() While iIndex > 0 iIndex -= 1 kItem = akTarget.GetNthForm(iIndex) fWeight = kItem.GetWeight() If !fWeight fWeight = 0.0001 EndIf If (kItem.GetGoldValue() / fWeight) >= PilferGlobal.GetValue() As Float akTarget.RemoveItem(kItem, akTarget.GetItemCount(kItem), True, PlayerREF) EndIf EndWhile EndIfEndEvent