Jump to content

Recommended Posts

Posted

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?

Posted

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.

Posted (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 by wilwhitt56
Posted

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 

 

 

Posted

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?

  • Recently Browsing   0 members

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