scriptName _00E_TraderLevelUp extends ObjectReference Event OnReset() if DebugMode.GetValue() == 1 debug.MessageBox("Object reseted") EndIf hIndex = CurrentIndex While hIndex if PlayerLevel.GetValue() >= LevelTreshold[CurrentIndex] RemoveItems() EndIf endwhile EndEvent Event OnLoad() Int ThresholdCount = LevelTreshold.Length Int ItemListCount = ItemList.Length if CurrentIndex >= ThresholdCount if DebugMode.GetValue() == 1 Debug.MessageBox("Max Wert erreicht") EndIf Return EndIf if ThresholdCount != ItemListCount Debug.messageBox("Error report: Trader interface. Threshold count and ItemList count are NOT the same! It will result in unexpected behavior.") EndIf jIndex = ThresholdCount While jIndex if PlayerLevel.GetValue() >= LevelTreshold[CurrentIndex] AddItems() EndIf if CurrentIndex >= ThresholdCount jIndex = 0 EndIf endwhile EndEvent Function AddItems() iIndex = ItemList[CurrentIndex].GetSize() While iIndex iIndex -= 1 Self.AddItem(ItemList[CurrentIndex].GetAt(iIndex)) endwhile CurrentIndex += 1 if DebugMode.GetValue() == 1 Debug.messageBox("Index at" + CurrentIndex) EndIf EndFunction Function RemoveItems() iIndex = ItemList[CurrentIndex].GetSize() While iIndex iIndex -= 1 Self.RemoveItem(ItemList[CurrentIndex].GetAt(iIndex)) endwhile CurrentIndex -= 1 if DebugMode.GetValue() == 1 Debug.messageBox("Index at" + CurrentIndex) endif EndFunction GlobalVariable Property PlayerLevel Auto GlobalVariable Property DebugMode AUto Formlist[] Property ItemList Auto Int[] Property LevelTreshold Auto Int CurrentIndex = 0 Int iIndex int jIndex int hIndex