Jump to content

Script for passing time or sleeping


spligitmoose

Recommended Posts

I'm at my wits end trying to make a script that passes a certain amount of in game time or even makes the player sleep/wait for that amount of time after activating an object. The Creation Kit wiki has this function: SetPCSleepHours iHours but I can't get it to compile in any variation of function usage.

 

Here's my script atm:

 

Scriptname SalvagingScript extends ObjectReference
{Give the player an item when they activate this reference.}

Form property ItemToGive Auto const
{The Item to give to the player when this references is activated.}

int property iNumberToGiveMin = 1 Auto const
{How many of the item are given? If always the same, Min and Max should be equal. Otherwise it's a random value between min/max}
int property iNumberToGiveMax = 1 Auto const
{If Greater than the Min, the number given will be randomized between that value and this one.}
float property fminSalvageTime = 1.0 Auto const
{minmum possible salvage time}
float property fmaxSalvageTime = 1.0 Auto const

bool property bDisableWhenDone = FALSE auto const
{Should this object disable when clicked? False by default.}

Auto State Initial
Event OnActivate(ObjectReference akActionRef)

bool isCombat = Game.getPlayer().IsInCombat()
if isCombat==true
;Cannot salvage in combat
;putmessage here
GoToState("Done")
endif
int iNumberToGive
float fSalvageTime
if (iNumberToGiveMin >= iNumberToGiveMax)
; If Min==Max or if the range is invalid, then just give the number in Min
iNumberToGive = iNumberToGiveMin
else
; if Min < Max, then generate a random whole number between.
iNumberToGive = utility.randomInt(iNumberToGiveMin,iNumberToGiveMax)
fSalvageTime = utility.randomFloat(fminSalvageTime,fmaxSalvageTime)
endif
akActionRef.AddItem(ItemToGive, iNumberToGive)
if bDisableWhenDone
; make this object go away. Generally for things which are being "taken" like a stack of noodle bowls, etc
disable()
else
;Makes player take time to salvage.
Game.SetPCSleepHours(fSalvageTime)
; otherwise just block future activation.
GoToState("Done")
endif
EndEvent
EndState

 

 

It's supposed to check if the player is combat, add items to their inventory and then pass time after the object the script is attached to is activated. It's an edit of Bethesda's DeafultAddItemOnActivate script which worked perfectly well but now I want to add the time component.

 

Thanks in advance for even looking this over.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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