Jump to content

Once a day script help


DEATHWALKER95

Recommended Posts

I need to make this script so that each time you press one of the buttons you cant use it again until the next day:

 

 

scn GSChemistrySetScript2
short Button
begin OnActivate
if IsActionRef player
ShowMessage GSChemistrySetMsg
endif
end
BEGIN MenuMode 1001
set Button to GetButtonPressed
if ( Button == 1 )
player.AddItem Stimpak 5
elseif ( Button == 2 )
player.AddItem Psycho 1
player.AddItem Buffout 1
player.AddItem Mentats 1
player.AddItem NVSteadyChem 1
player.AddItem NVReboundChem 1
endif
END
Link to comment
Share on other sites

I could only find two time functions, GetCurrentTime (current time in 24 hour format) and GetDayOfWeek (returns 0-6). Unfortunately, there's no date function, so there's no way to tell if a full week has passed without a constant script call.

 

Here's the solution without a GameMode block:

 

short time_initialized
float last_use_time
short last_use_day
float current_time

begin MenuMode 1001
  if time_initialized != 1
    set last_use_day to -1
    set last_use_time to -24
    set time_initialized to 1
  endif
  set current_time to GetCurrentTime
  if last_use_day != GetDayOfWeek
    set current_time to current_time + 24
  endif
  if current_time - last_use_time < 24
    ; display your failure message
  else
    ; do your action
    set last_use_time to GetCurrentTime
    set last_use_day to GetDayOfWeek
  endif
end
 

 

 

Variables are in an undefined state before they're initialized, and all comparisons fail. So you don't want to check "tme_initialized == 0", for example.

 

Unfortunately, the above code will fail if the menu is called precisely 1 week after it was last called, since DayOfWeek will be the same. The only solution I can think of is slightly ugly:

 

 

begin GameMode
    if last_use_day != GetDayOfWeek
      set last_use_day to -1
    endif
end

 

 

The idea there is the script is constantly checking if the day has changed, and if it has, it records that. Seems overkill to be doing that every frame, but I can't think of another reliable answer.

Link to comment
Share on other sites

Use the GameDaysPassed global. When used, set a persistent variable (Quest, usually) to GameDaysPassed. Check the current GameDaysPassed against your set variable +1. I.E. 'If (GameDaysPassed >= (fUsedLast + 1))'
Link to comment
Share on other sites

Chem set script:

scn GSChemistrySetScript2



short Button



begin OnActivate


if IsActionRef player
ShowMessage GSChemistrySetMsg
endif


end


BEGIN MenuMode 1001


set Button to GetButtonPressed


if MyQuest.WaitaDay == 0

if ( Button == 1 )

player.AddItem Stimpak 5

set MyQuest.CDay to GameDaysPassed + 1

set MyQuest.WaitaDay to 1

elseif ( Button == 2 )
player.AddItem Psycho 1
player.AddItem Buffout 1
player.AddItem Mentats 1
player.AddItem NVSteadyChem 1
player.AddItem NVReboundChem 1

set MyQuest.CDay to GameDaysPassed + 1

set MyQuest.WaitaDay to 1

endif

endif



END
 

Seperate quest script (Start Game Enabled has to be checked):

scn MyQuestSCRIPT

short WaitaDay
float CDay



Begin GameMode



if WaitaDay == 1 && GameDaysPassed >= CDay

set WaitaDay to 0

endif



end
 
Link to comment
Share on other sites

@nonplusultra - that will work, but there's no need to add the overhead of a gameMode quest script. Simply have two different messages, and use a questVar to store GameDaysPassed at the last time the 'generate loot' buttons were pressed. Then do a check against the current value of GameDaysPassed during the onActivate block. If more than 24 hours have passed, show the 'gimme loot' message. If fewer have passed, show the 'needs more time' message.

 

You'd also need to set a menu flag for handling different message forms and buttons, but that's no biggie.

Link to comment
Share on other sites

Oh true, I've worked too many with quests the last time, sry.

 

You should create a new global to save the current value of gamedayspassed, so we can skip the quest script completely.

 

 

P.S.: @ xaranth; do you have an idea about my issue? url: http://forums.nexusmods.com/index.php?/topic/928384-setpos-and-mesh-collisions/

Edited by nonplusultra
Link to comment
Share on other sites

  • Recently Browsing   0 members

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