Scg666Mod Posted April 12, 2015 Share Posted April 12, 2015 Hi guys got a script to add an item to the player on activate and would like to limit the number of times it can be used per day can anyone provide a script for this? My script(sorry for any errors this was typed on a phone from memory but the real one works fine) Potion Property SCG_Mead auto Event OnActivate(ObjectReference akActivate) Game.GetPlayer().AddItem(SCG_Mead)endEvent Link to comment Share on other sites More sharing options...
cdcooley Posted April 12, 2015 Share Posted April 12, 2015 There are a few different ways to do that. One of the easiest is if you want to limit to only once per day or once every 6 hours, etc. Potion Property SCG_Mead auto State UsedRecently Event OnActivate(ObjectReference akActivate) Debug.Notification("Only once every 6 hours") EndEvent EndState Event OnActivate(ObjectReference akActivate) GoToState("UsedRecently") RegisterForSingleUpdateGameTime(6.0) ; 6 Hours until a reset Game.GetPlayer().AddItem(SCG_Mead) EndEvent Event OnUpdateGameTime() GoToState("") EndEvent Link to comment Share on other sites More sharing options...
Scg666Mod Posted April 12, 2015 Author Share Posted April 12, 2015 Thanks that looks really good I coul definitely use that and in more than one part of the mod. The only thing I would add is I'm making a working mead barrel, would it be possible to limit it to 12 bottles a day? Link to comment Share on other sites More sharing options...
Scg666Mod Posted April 12, 2015 Author Share Posted April 12, 2015 Thanks that looks really good I coul definitely use that and in more than one part of the mod. The only thing I would add is I'm making a working mead barrel, would it be possible to limit it to 12 bottles a day? Link to comment Share on other sites More sharing options...
cdcooley Posted April 13, 2015 Share Posted April 13, 2015 Maybe this? (And that previous script is missing a parameter for AddItem that is fixed here.) Potion Property SCG_Mead auto int stockAvailable = 12 State UsedRecently Event OnActivate(ObjectReference akActivate) if stockAvailable > 0 stockAvailable -= 1 Game.GetPlayer().AddItem(SCG_Mead, 1) Debug.Notification(stockAvaliable + " bottles left.") else Debug.Notification("Only 12 per day.") endif EndEvent EndState Event OnActivate(ObjectReference akActivate) GoToState("UsedRecently") RegisterForSingleUpdateGameTime(24.0) ; restock 24 hours after first bottle taken OnActivate(akActivate) ; call the used recently version to give the first bottle EndEvent Event OnUpdateGameTime() stockAvailable = 12 GoToState("") EndEvent Link to comment Share on other sites More sharing options...
Scg666Mod Posted April 13, 2015 Author Share Posted April 13, 2015 Thanks I'll give it a shot :D Link to comment Share on other sites More sharing options...
Recommended Posts