Scriptname czAddGold extends ObjectReference ;This tells the engine some stuff that isn't very important at the moment. ;If you want to learn more about what all this means, look on the wiki.I hope the code and my comments helped you understand what is going on. Now, as I said earlier, the property isn't exactly "correctly" set up with just this code attached to an object. If you ran this and used the object it's attached to it would not give you any gold. Oh no! Don't worry though, it's simple to get the desired effect. Find the object you attached the script to and then find the button that says "Properties" under add/remove script (I believe). You'll see our beautiful variable czGoldCoin all alone, with no value attached to it. Let's help a girl out (variable genders are a separate topic that need not be discussed) and click her. You'll see a drop down menu and find Gold001. There we go, now the script knows where Gold001 is and can properly give it to the player.MiscObject Property czGoldCoin Auto ;Gold coins are now a property of this script.Event OnActivate(ObjectReference czUser) ;Everything between here and EndEvent will be processed when the object's activated. game.getplayer().additem(czGoldCoin, 100) ;Look familiar? This is very similar to the console command additem. ;This simply adds 100 gold coins to the player's inventory.EndEvent
Int property MyIndex AutoWeapon property MyWeapon AutoActor property Player AutoGlobalVariable property NumTries AutoEvent OnActivate(ObjectReference akActionRef) If akActionRef == Player If NumTries.GetValue() == 0 Debug.Notification("Nothing happens") Else If MyIndex == 1 Debug.Notification("Correct!") Player.AddItem(MyWeapon, 1, false) NumTries.SetValue(0) Else Debug.Notification("Incorrect") NumTries.SetValue(NumTries.GetValue() - 1) EndIf EndIf EndIf EndEvent
Int property MyIndex AutoWeapon property MyWeapon AutoSpell property MySpell AutoSpell property MyOtherSpell AutoActor property Player AutoGlobalVariable property NumTries AutoEvent OnActivate(ObjectReference akActionRef) If akActionRef == Player If NumTries.GetValue() == 0 Debug.Notification("Nothing happens") Else If MyIndex == 1 Debug.Notification("Stone 1 selected") Player.AddItem(MyWeapon, 1, false) NumTries.SetValue((NumTries.GetValue() - 1) ElseIf MyIndex == 2 Debug.Notification("Stone 2 selected") Player.AddSpell(MySpell, false) NumTries.SetValue(NumTries.GetValue() - 1) ElseIf MyIndex == 3 Debug.Notification("Stone 3 selected") Player.AddSpell(MyOtherSpell, false) NumTries.SetValue(NumTries.GetValue() - 1) EndIf EndIf EndIf EndEvent