wilwhitt56 Posted January 24, 2022 Share Posted January 24, 2022 Made a script for a triggerbox that activates a message, but ran into a snag. The triggerbox works, but it spams the message until you get out of it. What script do I need to use to make it activate only once? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 24, 2022 Share Posted January 24, 2022 You can use a bool variable to prevent a portion of the event from running again.You can use states to completely avoid the event at subsequent times. However, it would be best if we could see the script code in question along with the precise behavior you want. Link to comment Share on other sites More sharing options...
wilwhitt56 Posted January 24, 2022 Author Share Posted January 24, 2022 (edited) Scriptname CGEnterHouseTrigScript extends ObjectReference Message Property CGEntHouseMessage Auto Event OnTrigger(ObjectReference akActionRef)CGEntHouseMessage.show()EndEvent Just wanting it so that when you walk through it a message pops up and activates just once, and that's it. Edited January 24, 2022 by wilwhitt56 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 25, 2022 Share Posted January 25, 2022 Use OnTriggerEnter as opposed to OnTrigger. OnTrigger will keep spamming like crazy while the object that triggered it remains inside.. OnTriggerEnter will do it only when the trigger is entered. But alone it will continue to trigger with each entry into the trigger. If you do not need the trigger for anything else, you can have it disable itself. See if the following works for you (please test re-entering the trigger area multiple times). Also be sure to test on a new game or a game that has not seen this trigger at the very least. Scriptname CGEnterHouseTrigScript extends ObjectReference Message Property CGEntHouseMessage Auto Event OnTriggerEnter(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() ;limit to player CGEntHouseMessage.show() Utility.Wait(0.25) Self.Disable() EndIf EndEvent Link to comment Share on other sites More sharing options...
wilwhitt56 Posted January 25, 2022 Author Share Posted January 25, 2022 Use OnTriggerEnter as opposed to OnTrigger. OnTrigger will keep spamming like crazy while the object that triggered it remains inside.. OnTriggerEnter will do it only when the trigger is entered. But alone it will continue to trigger with each entry into the trigger. If you do not need the trigger for anything else, you can have it disable itself. See if the following works for you (please test re-entering the trigger area multiple times). Also be sure to test on a new game or a game that has not seen this trigger at the very least. Scriptname CGEnterHouseTrigScript extends ObjectReference Message Property CGEntHouseMessage Auto Event OnTriggerEnter(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() ;limit to player CGEntHouseMessage.show() Utility.Wait(0.25) Self.Disable() EndIf EndEvent Yep it's working. I'm assuming self.disable() means it turns off the trigger when it's done, but what does Utility.Wait(0.25) do? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 25, 2022 Share Posted January 25, 2022 It probably isn't needed. But I didn't want to risk any possible issues with timing. You could test without if you wish. Link to comment Share on other sites More sharing options...
Recommended Posts