Jump to content

[LE] Activation once per day


greyday01

Recommended Posts

Probably not what you're looking for exactly. But worth testing nonetheless. This will allow your activation to take place and then any time after put up a box that states it cannot be used. It uses a fixed time span rather than complicated math to turn on the ability to use at a specific time of day.

 

 

 

Bool IsUsable = true
 
Event OnActivate(ObjectReference akActivator)
  If akActivator == Game.GetPlayer()
    If IsUsable == true
      ;do your activation stuff
      IsUsable = false
      RegisterForSingleUpdateGameTime(24.0) ;waits a minimum of 24 game hours, can come later than 24 hours if sleeping / waiting / fast travel extends past the exact 24 hour mark.
    EndIf
  Else
    Debug.Messagebox("Unable to use this at this time")
  EndIf
EndEvent
 
Event OnUpdate()
  If IsUsable == false
    IsUsable = true
  EndIf
EndEvent

 

 

Edited by IsharaMeradin
Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

This script throws an error that it was expecting an EndIf, and I am not sure where to put it.

 

I am guessing that it's because you have 2 ifs, but only 1 endif? But as I said, I'm not sure where that 2nd endif goes.

 

If akActivator == Game.GetPlayer()
If IsUsable == true

Link to comment
Share on other sites

This script throws an error that it was expecting an EndIf, and I am not sure where to put it.

 

I am guessing that it's because you have 2 ifs, but only 1 endif? But as I said, I'm not sure where that 2nd endif goes.

 

If akActivator == Game.GetPlayer()

If IsUsable == true

Good catch, updated the code posted earlier.

Link to comment
Share on other sites

  • 4 months later...
Hi there,
I want to make a similar script on an activator that gives me a dragon soul once per day. I tried using the script above, but it doesn't work. This is the original script I am using, which is working so far every time when triggering the activator:

 

Scriptname aaMTGF_AbsorbDragonSoulScript extends ObjectReference

import utility
import game

Event OnActivate(ObjectReference akActivator)
Game.GetPlayer().modActorValue("dragonsouls", 1)

; effects
DragonAbsorbEffect.Play(self, 8, GetPlayer())
DragonAbsorbManEffect.Play(GetPlayer(), 8, self)
; Sounds for when the wispy particles being to fly at the player.
NPCDragonDeathSequenceWind.play(self)
NPCDragonDeathSequenceExplosion.play(self)

wait(0.1)

; On man power absorb effect shader.
DragonPowerAbsorbFXS.Play(GetPlayer())

wait(4)
;Stop fx shader on player showing power absorb.
DragonPowerAbsorbFXS.Stop(GetPlayer())

wait(4)

; Get rid of art attached to dragon and player showing streaming magic.
DragonAbsorbEffect.Stop(self)
DragonAbsorbManEffect.Stop(GetPlayer())

EndEvent

; absorb effects:
VisualEffect Property DragonAbsorbEffect Auto
VisualEffect Property DragonAbsorbManEffect Auto
sound property NPCDragonDeathSequenceWind auto
sound property NPCDragonDeathSequenceExplosion auto
EffectShader Property DragonPowerAbsorbFXS Auto

 

What I have to change exactly that my script is working only once per day? Any help is appriciated.
Edited by Wahnfried1883
Link to comment
Share on other sites

It should look like this:

Scriptname aaMTGF_AbsorbDragonSoulScript extends ObjectReference 

import utility
import game

Bool Usable = true

Event OnActivate(ObjectReference akActivator)
    
    If (akActivator As Actor) == GetPlayer() 
        If Usable == True
            Usable = False
            Game.GetPlayer().modActorValue("dragonsouls", 1)

            ; effects
            DragonAbsorbEffect.Play(self, 8, GetPlayer())
            DragonAbsorbManEffect.Play(GetPlayer(), 8, self)
            ; Sounds for when the wispy particles being to fly at the player.
            NPCDragonDeathSequenceWind.play(self)
            NPCDragonDeathSequenceExplosion.play(self)

            wait(0.1)

            ; On man power absorb effect shader.
            DragonPowerAbsorbFXS.Play(GetPlayer())

            wait(4)
            ;Stop fx shader on player showing power absorb.
            DragonPowerAbsorbFXS.Stop(GetPlayer())

            wait(4)

            ; Get rid of art attached to dragon and player showing streaming magic.
            DragonAbsorbEffect.Stop(self)
            DragonAbsorbManEffect.Stop(GetPlayer())
            RegisterForSingleUpdateGameTime(24.0) ;udates in 24 hours
        Else 
            Debug.MessageBox("Can only be used once a day.") 
        Endif
    Endif
EndEvent

Event OnUpdateGameTime()
    Usable = true 
EndEvent

; absorb effects:
VisualEffect Property DragonAbsorbEffect Auto
VisualEffect Property DragonAbsorbManEffect Auto
sound property NPCDragonDeathSequenceWind auto
sound property NPCDragonDeathSequenceExplosion auto
EffectShader Property DragonPowerAbsorbFXS Auto

 

 

Edited by dylbill
Link to comment
Share on other sites

just a version with two boolVars, instead of one .. nothings special

aaMTGF_AbsorbDragonSoulScript

 

Scriptname aaMTGF_AbsorbDragonSoulScript extends ObjectReference
; https://forums.nexusmods.com/index.php?/topic/8351218-activation-once-per-day/

  EffectShader PROPERTY DragonPowerAbsorbFXS auto

  VisualEffect PROPERTY DragonAbsorbEffect    auto
  VisualEffect PROPERTY DragonAbsorbManEffect auto

  Sound PROPERTY NPCDragonDeathSequenceWind      auto
  Sound PROPERTY NPCDragonDeathSequenceExplosion auto

  Bool bBusy        ; [default=False]
  Bool bDone        ; [default=False]


; -- EVENTs -- 2

; https://www.creationkit.com/index.php?title=Play_-_VisualEffect

EVENT OnUpdateGameTime()
; after 24 hours reset our boolVars
    bBusy = False
    bDone = False
ENDEVENT


EVENT OnActivate(ObjectReference akActionRef)
IF (akActionRef == Game.GetPlayer() as ObjectReference)
ELSE
    RETURN    ; - STOP -    not player activated
ENDIF
;---------------------
IF ( bBusy )
    IF ( bDone )
        ; give message only, after the whole absorbing is done
        Debug.MessageBox("Can only be used once a day.")
    ENDIF
    RETURN    ; - STOP -    boolVar is TRUE, do nothing
ENDIF
;---------------------
    bBusy = TRUE
    (akActionRef as Actor).ModActorValue("dragonsouls", 1.0)

; start visual effects
    DragonAbsorbEffect.Play(self as ObjectReference, 8.0, akActionRef)           ; -> 1
    DragonAbsorbManEffect.Play(akActionRef, 8.0, self as ObjectReference)        ; -> 2

; Sounds for when the wispy particles being to fly at the player.
    NPCDragonDeathSequenceWind.Play(self as ObjectReference)
    NPCDragonDeathSequenceExplosion.Play(self as ObjectReference)
    Utility.Wait(0.1)

    DragonPowerAbsorbFXS.Play(akActionRef)            ; -> 3 shaderFX on
    Utility.Wait(4.0)
    DragonPowerAbsorbFXS.Stop(akActionRef)            ; <- 3 shaderFX off

    Utility.Wait(4.0)

; stop both visuals after 8 sec, get rid of art attached to dragon and player showing streaming magic.
    DragonAbsorbManEffect.Stop(akActionRef)                                      ; <- 2
    DragonAbsorbEffect.Stop(self as ObjectRefeence)                              ; <- 1

; register for 24 hours ingame waiting
    RegisterForSingleUpdateGameTime(24.0)

; absorbing is over, show message by activation now
    bDone = TRUE
ENDEVENT

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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