


ScriptName ContainerWeightScript extends ObjectReferenceFloat fWeightFormList Property FormListOfFormListsFLST Auto ; Has all the others in itFormList Property HalfPoundFLST AutoFormList Property OnePoundFLST AutoFormList Property TwoPoundFLST AutoFormList Property ThreePoundFLST AutoFormList Property FourPoundFLST AutoFormList Property FivePoundFLST AutoFormList Property TenPoundFLST AutoEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) fWeight = GetContainerWeight(Self) If (fWeight > 9000) RemoveItem(akBaseItem, 1, True, akSourceContainer) Debug.MessageBox("This thing is stuffed! Remove items to make room.") EndIf EndEvent;===============================================Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) fWeight = GetContainerWeight(Self) If (fWeight > 9000) If HalfPoundFLST.HasForm(akBaseItem) fWeight -= 0.5 ElseIf OnePoundFLST.HasForm(akBaseItem) fWeight -= 1 ElseIf TwoPoundFLST.HasForm(akBaseItem) fWeight -= 2 ElseIf ThreePoundFLST.HasForm(akBaseItem) fWeight -= 3 ElseIf FourPoundFLST.HasForm(akBaseItem) fWeight -= 4 ElseIf FivePoundFLST.HasForm(akBaseItem) fWeight -= 5 ElseIf TenPoundFLST.HasForm(akBaseItem) fWeight -= 6 EndIf EndIfEndEvent;===============================================Float Function GetContainerWeight(ObjectReference akContainer = None, FormList akFormList = None, Int aiIndex = 0, Int aiCount = 0) fWeight = 0 aiIndex = (FormListOfFormListsFLST.GetSize() - 1) While (aiIndex > -1) akFormList = FormListOfFormListsFLST.GetAt(aiIndex) As FormList aiCount = akContainer.GetItemCount(akFormList) If (aiIndex == 6) ; 10 'pound' items fWeight += (aiCount * 10) As Float ElseIf (aiIndex == 5) ; 5 'pound' items fWeight += (aiCount * 5) As Float ElseIf (aiIndex == 4) ; 4 'pound' items fWeight += (aiCount * 4) As Float ElseIf (aiIndex == 3) ; 3 'pound' items fWeight += (aiCount * 3) As Float ElseIf (aiIndex == 2) ; 2 'pound' items fWeight += (aiCount * 2) As Float ElseIf (aiIndex == 1) ; 1 'pound' items fWeight += (aiCount * 1.0) As Float ElseIf (aiIndex == 0) ; .5 'pound' items fWeight += (aiCount * 0.5) As Float EndIf aiIndex -= 1 EndWhile Return fWeightEndFunctionScriptName ContainerWeightScript extends ObjectReferenceFloat fWeightFormList Property FormListOfFormListsFLST Auto ; Has all the others in itFormList Property HalfPoundFLST AutoFormList Property OnePoundFLST AutoFormList Property TwoPoundFLST AutoFormList Property ThreePoundFLST AutoFormList Property FourPoundFLST AutoFormList Property FivePoundFLST AutoFormList Property TenPoundFLST AutoEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) fWeight = GetContainerWeight(Self) If (fWeight > 9000) RemoveItem(akBaseItem, 1, True, akSourceContainer) Debug.MessageBox("This thing is stuffed! Remove items to make room.") EndIf EndEvent;===============================================Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) fWeight = GetContainerWeight(Self) If (fWeight > 9000) If HalfPoundFLST.HasForm(akBaseItem) fWeight -= 0.5 ElseIf OnePoundFLST.HasForm(akBaseItem) fWeight -= 1 ElseIf TwoPoundFLST.HasForm(akBaseItem) fWeight -= 2 ElseIf ThreePoundFLST.HasForm(akBaseItem) fWeight -= 3 ElseIf FourPoundFLST.HasForm(akBaseItem) fWeight -= 4 ElseIf FivePoundFLST.HasForm(akBaseItem) fWeight -= 5 ElseIf TenPoundFLST.HasForm(akBaseItem) fWeight -= 6 EndIf EndIfEndEvent;===============================================Float Function GetContainerWeight(ObjectReference akContainer = None, FormList akFormList = None, Int aiIndex = 0, Int aiCount = 0) fWeight = 0 aiIndex = (FormListOfFormListsFLST.GetSize() - 1) While (aiIndex > -1) akFormList = FormListOfFormListsFLST.GetAt(aiIndex) As FormList aiCount = akContainer.GetItemCount(akFormList) If (aiIndex == 6) ; 10 'pound' items fWeight += (aiCount * 10) As Float ElseIf (aiIndex == 5) ; 5 'pound' items fWeight += (aiCount * 5) As Float ElseIf (aiIndex == 4) ; 4 'pound' items fWeight += (aiCount * 4) As Float ElseIf (aiIndex == 3) ; 3 'pound' items fWeight += (aiCount * 3) As Float ElseIf (aiIndex == 2) ; 2 'pound' items fWeight += (aiCount * 2) As Float ElseIf (aiIndex == 1) ; 1 'pound' items fWeight += (aiCount * 1.0) As Float ElseIf (aiIndex == 0) ; .5 'pound' items fWeight += (aiCount * 0.5) As Float EndIf aiIndex -= 1 EndWhile Return fWeightEndFunction