dontpanic Posted February 22, 2012 Share Posted February 22, 2012 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 More sharing options...
Pifanjr Posted February 22, 2012 Share Posted February 22, 2012 use RegisterForUpdateGameTime(float afInterval)see http://www.creationkit.com/RegisterForUpdateGameTime_-_Form for more information. Link to comment Share on other sites More sharing options...
dontpanic Posted March 1, 2012 Author Share Posted March 1, 2012 (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 March 1, 2012 by dontpanic Link to comment Share on other sites More sharing options...
dontpanic Posted March 1, 2012 Author Share Posted March 1, 2012 bump Link to comment Share on other sites More sharing options...
dontpanic Posted March 1, 2012 Author Share Posted March 1, 2012 bump Link to comment Share on other sites More sharing options...
Cipscis Posted March 1, 2012 Share Posted March 1, 2012 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 More sharing options...
dontpanic Posted March 1, 2012 Author Share Posted March 1, 2012 (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 March 1, 2012 by dontpanic Link to comment Share on other sites More sharing options...
Cipscis Posted March 1, 2012 Share Posted March 1, 2012 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 More sharing options...
dontpanic Posted March 1, 2012 Author Share Posted March 1, 2012 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 More sharing options...
Cipscis Posted March 1, 2012 Share Posted March 1, 2012 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 Link to comment Share on other sites More sharing options...
Recommended Posts