flyddon Posted December 27, 2016 Share Posted December 27, 2016 So I am in the middle of a quest and I need to write a script to check the players inventory for a specific ring, I created the ring (dup the silver ruby ring) and gave it a different name. Now I want , when the play enters a trigger box, a script to check players inventory for THAT ring and trigger an action. But the ring is NOT a quest item. Link to comment Share on other sites More sharing options...
SkyFireXxx Posted December 27, 2016 Share Posted December 27, 2016 So I am in the middle of a quest and I need to write a script to check the players inventory for a specific ring, I created the ring (dup the silver ruby ring) and gave it a different name. Now I want , when the play enters a trigger box, a script to check players inventory for THAT ring and trigger an action. But the ring is NOT a quest item. You need something like this - if (Game.GetPlayer().GetItemCount(YourRingRef) > 0) Debug.Trace("Player has the ring") endif Link to comment Share on other sites More sharing options...
flyddon Posted December 27, 2016 Author Share Posted December 27, 2016 Ok So questions does the (YourRingRef) mean the Ring Ref ID that I gave my ring when creating it NGIJRingSilverRuby001. And if so, I am guess this script would work on any item that has a unique ID ? Link to comment Share on other sites More sharing options...
SkyFireXxx Posted December 27, 2016 Share Posted December 27, 2016 Ok So questions does the (YourRingRef) mean the Ring Ref ID that I gave my ring when creating it NGIJRingSilverRuby001. And if so, I am guess this script would work on any item that has a unique ID ?YouRingRef (Or whatever name you want to give it) should be an ObjectReference property in your script which points to the ring you intend to give to the player.Yes, it should work on any item that has a unique ID. Link to comment Share on other sites More sharing options...
flyddon Posted December 27, 2016 Author Share Posted December 27, 2016 Prefect Thank you so much ! Does Event OnInit() mean the script will only run once? (unless reset) What I am trying to do here is have a script that is linked to a trigger to look in the players inventory see if he his the ring, if he does, enable xmarker, display message box then end (and never run again). If he does not have the ring have the script run each time player enters the trigger box. You helped me with the searching inventory part, I have the xmarker enable working, int state of xmarker is disable. but the damn message displays each time ..... hmmm let me think about this. **edit ** this is what I am testingScriptname NGIJOutsideTrigger extends ObjectReference ObjectReference Property NGIJoutsideXmarker AutoObjectReference Property NGIJRingSilverRuby001 Auto Event OnTriggerEnter(ObjectReference akActionRef)If akActionRef == Game.GetPlayer() If (Game.GetPlayer().GetItemCount(NGIJRingSilverRuby001) > 0) Debug.MessageBox("Someone is calling you!") NGIJoutsideXmarker.Enable() EndIfEndIfEndEvent Link to comment Share on other sites More sharing options...
SkyFireXxx Posted December 27, 2016 Share Posted December 27, 2016 Prefect Thank you so much ! Does Event OnInit() mean the script will only run once? (unless reset)No. The code will run every time the script or the object is initialized, that means anytime an object is reset OnInit will be called again. Link to comment Share on other sites More sharing options...
flyddon Posted December 27, 2016 Author Share Posted December 27, 2016 Prefect Thank you so much ! Does Event OnInit() mean the script will only run once? (unless reset)No. The code will run every time the script or the object is initialized, that means anytime an object is reset OnInit will be called again. OK so the scripts works almost prefectly. Does trip when it should (only when play has ring) and of course enable's the xmarker like I want and display message. However, every time player walks back into the trigger box I get the message again... I only need it he first time.... any help or hints? Scriptname NGIJOutsideTrigger extends ObjectReference ObjectReference Property NGIJoutsideXmarker Auto ObjectReference Property NGIJRingSilverRuby001 Auto Event OnTriggerEnter(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() if (Game.GetPlayer().GetItemCount(NGIJRingSilverRuby001) > 0) Debug.MessageBox("Someone is calling you!") NGIJoutsideXmarker.Enable() EndIf Endif EndEvent that "Debug.MessageBox("Someone is calling you!")" should only show once. Link to comment Share on other sites More sharing options...
cdcooley Posted December 27, 2016 Share Posted December 27, 2016 Try this: Scriptname NGIJOutsideTrigger extends ObjectReference ObjectReference Property NGIJoutsideXmarker Auto ObjectReference Property NGIJRingSilverRuby001 Auto Event OnTriggerEnter(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() if (Game.GetPlayer().GetItemCount(NGIJRingSilverRuby001) > 0) Debug.MessageBox("Someone is calling you!") NGIJoutsideXmarker.Enable() GoToState("Done") EndIf Endif EndEvent State Done Event OnTriggerEnter(ObjectReference akActionRef) EndEvent EndState Or you could do this: Scriptname NGIJOutsideTrigger extends ObjectReference ObjectReference Property NGIJoutsideXmarker Auto ObjectReference Property NGIJRingSilverRuby001 Auto Event OnTriggerEnter(ObjectReference akActionRef) If NGIJoutsideXmarker.IsDisabled() && akActionRef == Game.GetPlayer() if (Game.GetPlayer().GetItemCount(NGIJRingSilverRuby001) > 0) Debug.MessageBox("Someone is calling you!") NGIJoutsideXmarker.Enable() EndIf Endif EndEvent If the player will be moving through that trigger area many times throughout the game the first version is better. If it's a place that won't be visited often the second is also perfectly acceptable. Link to comment Share on other sites More sharing options...
flyddon Posted December 28, 2016 Author Share Posted December 28, 2016 Oh happy days! It works perfectly now. Thank you cdcooley, I went with the first code, as the player hopefully will be traveling in and out of his/her new player house often. Thanks again to both of you cdcooley and SkyFireXxx. Link to comment Share on other sites More sharing options...
SkyFireXxx Posted December 28, 2016 Share Posted December 28, 2016 You're welcome mate. Link to comment Share on other sites More sharing options...
Recommended Posts