Jump to content

[LE] How to make a trigger script activate once?


wilwhitt56

Recommended Posts

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

 

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
Link to comment
Share on other sites

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

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

  • Recently Browsing   0 members

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