Jump to content

Need script help for a timer.


dontpanic

Recommended Posts

I am trying to make a script that will give the player a certain amount of money every day or week game time. I am trying to use a dialog command to trigger the script, but I don't know how to set a timer for every so often player.additem 00000f (whatever amount). Any help would be greatly appreciated.
Link to comment
Share on other sites

Basically I am trying to give the player an income similar to how your wife or husband gives you money when they open a shop. Unfortunately I have been unsuccessful understanding how to make the timer work.

I tried using the following and it does not work. Can someone please help me with setting up the feature?

 

Scriptname aaIncomeScript extends Quest  


MiscObject Property Gold  Auto  ;I set the gold from the game for this

Event OnUpdateGameTime()
   ; Do some stuff
RegisterForUpdateGameTime(24)
Game.GetPlayer().AddItem(Gold) ;Unsure of how to give the player a certain amount.
endEvent

Edited by dontpanic
Link to comment
Share on other sites

If you look at the Creation Kit Wiki's documentation of AddItem, you can see that the amount is specified via a second parameter.

 

Currently, your script will only register for the OnUpdateGameTime if it's already registered, so there's no entry point for your code. You need to add another event for the initial registration.

 

Also, if you use RegisterForUpdateGameTime, then the object will remain registered until you call UnregisterForUpdateGameTime. You may instead want to use RegisterForSingleUpdateGameTime.

 

Cipscis

Link to comment
Share on other sites

How does this look?

Scriptname aaIncomeScript extends Quest  


MiscObject Property Gold  Auto  ;I set the gold from the game for this

Function SomeFunction()                       
 RegisterForUpdateGameTime(24) ; Before we can use onUpdateGameTime() we must register.
endFunction

Event OnUpdateGameTime() ; because of how we registered, this event occurs every 30 minutes of game time.
   UnregisterForUpdateGameTime()
   ; Do some stuff
   Game.GetPlayer().AddItem(Gold, 300, true) ; gives player 300 gold
   Debug.Trace("Got what we needed, so stop polling!")
endEvent

 

I am trying to get the player to receive the amount of gold every 7 days. Unfortunately I can't seem to get the script to work very well.

Edited by dontpanic
Link to comment
Share on other sites

You need an event like OnInit as an entry point, although that event in particular might not be appropriate. The "SomeFunction" function that you've created will never be called at the moment.

 

If you want the update to happen weekly, then you'll want to pass 168 (which is 24*7) to RegisterForUpdateGameTime. You should only call UnregisterForUpdateGameTime once you are ready for your script to stop running.

 

Cipscis

Link to comment
Share on other sites

I tried modifying the script like so and still no progress. Not sure what I am doing wrong. I have the variables tied to there appropriate assets, but I can't get the script to give me 300 gold every 7 days.

 

Scriptname aaIncomeScript extends Quest 


MiscObject Property Gold  Auto  ;I set the gold from the game for this
Quest Property  InnQuest  Auto

Event OnInit() ; This event will run once, when the script is initialized
RegisterForUpdateGameTime(24)
EndEvent

State polling	
Event OnUpdateGameTime()			
	if (InnQuest.GetStage() == 10)
                       Game.GetPlayer().AddItem(Gold, 300, true) ; gives player 300 gold
		Debug.Trace("Got what we needed, so stop polling!")
		
		
	endif
EndEvent
EndState

State active
; Do nothing in here
EndState

Link to comment
Share on other sites

  • Recently Browsing   0 members

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