Jump to content

Script help


Scg666Mod

Recommended Posts

Hi guys got a script to add an item to the player on activate and would like to limit the number of times it can be used per day can anyone provide a script for this?

 

My script(sorry for any errors this was typed on a phone from memory but the real one works fine)

 

Potion Property SCG_Mead auto

 

Event OnActivate(ObjectReference akActivate)

Game.GetPlayer().AddItem(SCG_Mead)

endEvent

Link to comment
Share on other sites

There are a few different ways to do that. One of the easiest is if you want to limit to only once per day or once every 6 hours, etc.

 

 

Potion Property SCG_Mead auto
 
State UsedRecently
   Event OnActivate(ObjectReference akActivate)
       Debug.Notification("Only once every 6 hours")
   EndEvent
EndState

Event OnActivate(ObjectReference akActivate)
    GoToState("UsedRecently")
    RegisterForSingleUpdateGameTime(6.0)  ;  6 Hours until a reset
    Game.GetPlayer().AddItem(SCG_Mead)
EndEvent
 
Event OnUpdateGameTime()
    GoToState("")
EndEvent
Link to comment
Share on other sites

Maybe this? (And that previous script is missing a parameter for AddItem that is fixed here.)

Potion Property SCG_Mead auto

int stockAvailable = 12

State UsedRecently
    Event OnActivate(ObjectReference akActivate)
        if stockAvailable > 0
            stockAvailable -= 1
            Game.GetPlayer().AddItem(SCG_Mead, 1)
            Debug.Notification(stockAvaliable + " bottles left.")
        else
            Debug.Notification("Only 12 per day.")
        endif
    EndEvent
EndState
 
Event OnActivate(ObjectReference akActivate)
    GoToState("UsedRecently")
    RegisterForSingleUpdateGameTime(24.0)  ; restock 24 hours after first bottle taken
    OnActivate(akActivate)  ; call the used recently version to give the first bottle
EndEvent
 
Event OnUpdateGameTime()
    stockAvailable = 12
    GoToState("")
EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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