Jump to content

Help with running scripts only once per game session


Recommended Posts

So, I'm trying to run a script that mods the players spell effectiveness with the OBSE function ModPCSpellEffectiveness for players that chose the apprentice birthsign, but it either does it ever 5 seconds when the quest script runs (which stacks it infinitely), or only once on character creation if i use a doonce variable. How do i set the quest so that it will trigger once every game load? Because when i exit the game it clears the spell effectiveness back to 100%, but the doonce variable stays set to 1, and won't run the script anymore. Right now the script looks something like this:

Short DoOnceApprentice

Begin Gamemode

If GetIsPlayerBirthsign BirthSignApprencetice && DoOnceApprentice == 0

ModPCSpellEffectiveness 0.1

Set DoOnceApprentice to 1

Endif

End

Link to comment
Share on other sites

Use GetGameLoaded to reset DoOnceApprentice flag:

Short DoOnceApprentice

Begin Gamemode
	if GetGameLoaded
		set DoOnceApprentice to 0
	endif
	If GetIsPlayerBirthsign BirthSignApprentice && DoOnceApprentice == 0
		ModPCSpellEffectiveness 0.1
		Set DoOnceApprentice to 1
	Endif
End

 

Link to comment
Share on other sites

Thanks, I've been looking for this function but i haven't been able to find anything online on the CS wiki or the forums, this will help me with a lot of scripts that i need to load once every game session.

Link to comment
Share on other sites

  On 5/5/2025 at 11:13 AM, RomanR said:

Use GetGameLoaded to reset DoOnceApprentice flag:

Short DoOnceApprentice

Begin Gamemode
	if GetGameLoaded
		set DoOnceApprentice to 0
	endif
	If GetIsPlayerBirthsign BirthSignApprentice && DoOnceApprentice == 0
		ModPCSpellEffectiveness 0.1
		Set DoOnceApprentice to 1
	Endif
End

 

Expand  

A small correction, what i was actually looking for was GetGameRestarted. The Spell effectiveness mod persisted through loads done in the same game session, so everytime i loaded back to a save or died it would reapply the spell effectiveness mod, it just cleared after exiting the game, so changing it to GetGameRestarted instead of GetGameLoaded worked perfectly.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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