Jump to content

[LE] simple gamble script


gunabuse

Recommended Posts

 

Scriptname _aaa_FiftyFifty Extends ObjectReference
;* Fifty gold, fifty percent of the time
MiscObject Property Gold001 Auto
Actor Property PlayerRef Auto
Int Property Gold Auto
;
Event OnInit()
GoToState("Done")
EndEvent
;
Event OnActivate(ObjectReference akActionRef)
If(akActionRef==(PlayerRef))
If(PlayerRef.GetItemCount(Gold001)>=(Gold))
If(Utility.RandomInt(0,1)==(0))
PlayerRef.AddItem(Gold001, Gold)
Else
PlayerRef.RemoveItem(Gold001, Gold)
EndIf
Else
; Debug.Notification("Not enough gold")
Endif
Endif
GoToState("Done")
EndEvent
;
State Done
;do nothing
EndState
;

 

 

This code is perfect as stands ... From the Creation Kit add 50 to the Gold Property. (or whatever amount you want)

Link to comment
Share on other sites

May i ask why do you go to a state both on init and after each time it runs, to never come back and then not add a single function to this "done" state? As far as i know and understand it is essentially picking the function from the empty state every time so the done state remains, to the best of my knowledge, useless.
Link to comment
Share on other sites

May i ask why do you go to a state both on init and after each time it runs, to never come back and then not add a single function to this "done" state? As far as i know and understand it is essentially picking the function from the empty state every time so the done state remains, to the best of my knowledge, useless.

You are correct ... Take that line out. That was for a different script that only ran once.

My bad, good eye.

 

You can auto fill Gold001 and PlayerRef, then make Gold 50 and it works fine.

Edited by NexusComa
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...