The line in the code that is larger font seems to be the offending piece. The code compiles and runs and does everything except this line. All I need is for this object to be removed from the player's inventory. I have already determined (Thanks WilleSea) that mySelf/Self referes to the script in this case and not the item to which the code is attached.
Any ideas how to accomplish this goal.
If I can get this to work, it will eliminate the problem where you buy too much from the vendor, causing their max gold limit to exceed.
If you have ever seen this situation, you end up selling all your stuff and not getting any gold for it. It's not fun.
What this code does is turn any gold over a set amount in the vendors inventory, into Skyrim "Septimus Notes" (Paper Money). You can then buy these from the vendor and resupply them with gold.
When you drop the "Septimus Note" and then pick it back up, it converts it back to Gold Septims.
It's a somewhat immersive way to eliminate one of the problems Bethesda made for us by putting limits on the amount of gold a vendor can have. More likely, they just used the wrong data type for the variable that tracks this value. Not sure.
Anyway, any suggestions anyone could offer will help me get this mod out sooner.
Scriptname FQSeptimusNoteExchangeScript extends ObjectReference
import debug
import utility
miscobject Property GoldRef Auto
Int Property maxVendorGold Auto
miscobject Property FQ100KSeptimusNote Auto
miscobject Property FQ50KSeptimusNoteSkyrim Auto
miscobject Property FQ40KSeptimusNoteSKYRIM Auto
miscobject Property FQ30KSeptimusNoteSKYRIM Auto
miscobject Property FQ20KSeptimusNoteSKYRIM Auto
miscobject Property FQ10KSeptimusNoteSKYRIM Auto
miscobject Property FQ5KSeptimusNoteSkyrim Auto
miscobject Property FQ4KSeptimusNoteSkyrim Auto
miscobject Property FQ3KSeptimusNoteSkyrim Auto
miscobject Property FQ2KSeptimusNoteSkyrim Auto
miscobject Property FQ1KSeptimusNoteSkyrim Auto
MiscObject Property FQSPENTSeptimusNoteSkyrim Auto
MiscObject property coinObj auto
Int property coinAmt auto
MiscObject mySelf
auto State Waiting
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
mySelf = self.getBaseObject() as MiscObject
Debug.Notification("OnItemChangedContainer")
Debug.Notification("akOldContainer = " + akOldContainer); None
Debug.Notification("akNewContainer = " + akNewContainer); ObjectReference
if akNewContainer == Game.GetPlayer()
Debug.Notification("akNewContainer == Game.GetPlayer()")
if !akOldContainer
Debug.Notification("!akOldContainer")
gotoState("done")
int numOfCoins = coinAmt
[size=6] game.getplayer().removeitem(mySelf, 1, abSilent = true)[/size]
game.getPlayer().addItem(coinObj, numOfCoins)
game.getPlayer().addItem(FQSPENTSeptimusNoteSkyrim,1, abSilent = false)
elseif akOldContainer
Debug.Notification("akOldContainer")
SeptimusNoteExchange(akOldContainer)
endif
endif
endEvent
endState
State done
;do nothing
endState
Function SeptimusNoteExchange(ObjectReference akTargetRef)
Debug.Notification("Now we're debuggin the SeptimusNoteExchange function!")
ObjectReference VendorRef = akTargetRef
int currentVendorGold = VendorRef.GetItemCount(GoldRef)
int amtOverMaxVendorGold = currentVendorGold - maxVendorGold
Debug.Notification("The amtOverMaxVendorGold is " + amtOverMaxVendorGold)
while amtOverMaxVendorGold >= 1000
if amtOverMaxVendorGold >= 100000
VendorRef.additem(FQ100KSeptimusNote, 1, false)
VendorRef.removeitem(GoldRef, 100000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 100000
endif
if amtOverMaxVendorGold >= 50000
VendorRef.additem(FQ50KSeptimusNoteSkyrim, 1, false)
VendorRef.removeitem(GoldRef, 50000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 50000
endif
if amtOverMaxVendorGold >= 40000
VendorRef.additem(FQ40KSeptimusNoteSKYRIM, 1, false)
VendorRef.removeitem(GoldRef, 40000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 40000
endif
if amtOverMaxVendorGold >= 30000
VendorRef.additem(FQ30KSeptimusNoteSKYRIM, 1, false)
VendorRef.removeitem(GoldRef, 30000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 30000
endif
if amtOverMaxVendorGold >= 20000
VendorRef.additem(FQ20KSeptimusNoteSKYRIM, 1, false)
VendorRef.removeitem(GoldRef, 20000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 20000
endif
if amtOverMaxVendorGold >= 10000
VendorRef.additem(FQ10KSeptimusNoteSKYRIM, 1, false)
VendorRef.removeitem(GoldRef, 10000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 10000
endif
if amtOverMaxVendorGold >= 5000
VendorRef.additem(FQ5KSeptimusNoteSkyrim, 1, false)
VendorRef.removeitem(GoldRef, 5000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 5000
endif
if amtOverMaxVendorGold >= 4000
VendorRef.additem(FQ4KSeptimusNoteSkyrim, 1, false)
VendorRef.removeitem(GoldRef, 4000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 4000
endif
if amtOverMaxVendorGold >= 3000
VendorRef.additem(FQ3KSeptimusNoteSkyrim, 1, false)
VendorRef.removeitem(GoldRef, 3000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 3000
endif
if amtOverMaxVendorGold >= 2000
VendorRef.additem(FQ2KSeptimusNoteSkyrim, 1, false)
VendorRef.removeitem(GoldRef, 2000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 2000
endif
if amtOverMaxVendorGold >= 1000
VendorRef.additem(FQ1KSeptimusNoteSkyrim, 1, false)
VendorRef.removeitem(GoldRef, 1000, false)
amtOverMaxVendorGold = amtOverMaxVendorGold - 1000
else
Debug.Notification("The amtOverMaxVendorGold is less than 1000 at " + amtOverMaxVendorGold)
endif
endwhile
EndFunction