Jump to content

Recommended Posts

Posted
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.
Posted (edited)

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
Posted

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

Posted (edited)

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
Posted

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

Posted

If your state doesn't use the "auto" keyword, you need to use GoToState or your script won't enter that state. Functions and events defined within a state will only have that version run while the script is currently in their state.

 

Cipscis

  • Recently Browsing   0 members

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