Jump to content

Script problem Please help


Agnot2006

Recommended Posts

This scrip works attached to a trigger box but the sound is played on entering boxes all over the game. I removed the trigger but the sound still played. I found that it was the script once removed the problem stopped. The sound file ID is specific to my mod.

What have I done wrong?

 

scn ExpansionMySoundSB

 

begin OnTriggerEnter

Playsound MySoundSB

End

:confused:

Link to comment
Share on other sites

You did not include a DoOnce argument to your script, so the sound plays continuously once triggered, even though it is not set to loop:

 

scn ExpansionMySoundSB

 

short DoOnce

 

begin OnTriggerEnter

if DoOnce == 0

Playsound MySoundSB

Set DoOnce to 1

endif

End

 

If you want the sound to play more than once, you will need a mechanism to reset DoOnce to 0. If you do not want NPCs or creatures to trigger the sound, then change to OnTriggerEnterPlayer.

 

You need to create a unique trigger box. When you edited the trigger box and added your script to it, I am guessing that you did not rename the trigger box and save it as a unique ID. That would explain why the sound is playing in places that you did not intend.

Link to comment
Share on other sites

Fantastic thank you.

Do I have to set the DoOnce to 0 before the OnTriggerEnter will work again? Or is it automatically reset once the trigger condition is no longer present?

Link to comment
Share on other sites

Fantastic thank you.

Do I have to set the DoOnce to 0 before the OnTriggerEnter will work again? Or is it automatically reset once the trigger condition is no longer present?

You will have to make a way for it to reset to 0. I have used proximity ( i.e. if player.getdistance > 120 ), changing cells ( i.e. if player.GetInWorldspace Wasteland ), timers, other trigger boxes, quest stages and scripts attached to packages and lines of dialogue to set conditions. I'm sure that more methods could be imagined, but your DoOnce condition will not reset to 0 without some sort of mechanism.

Link to comment
Share on other sites

So I could use an OnTriggerLeave to set it back to zero then?

It's worth a try. I found this script in vanilla FO3 that seems to change actor variables tat way:

 

scn TrigCapitolBuildingBehemothHide04SCRIPT

 

Begin onTriggerEnter Player

 

if ( CapitolBehemothREF.IsInCombat == 1 )

if ( CapitolBehemothREF.GetCombatTarget == Player )

CapitolBehemothREF.setav Variable04 1

CapitolBehemothREF.evp

endif

endif

End

 

Begin onTriggerLeave Player

CapitolBehemothREF.setav Variable04 0

CapitolBehemothREF.evp

End

 

Maybe change it to something like:

 

scn ExpansionMySoundSB

 

short DoOnce

 

Begin onTriggerEnter Player

 

if DoOnce == 0

Playsound MySoundSB

Set DoOnce to 1

endif

End

 

Begin onTriggerLeave Player

 

if DoOnce == 1

Set DoOnce to 0

endif

End

 

It might work fine. If it doesn't, just have to try something else.

If you want NPCs or creatures to trigger the sound, just drop the "Player" part of the if statement.

 

Have to try that myself. Thanks. :thumbsup:

Link to comment
Share on other sites

Thank You BadPenny - Kudos

This works great. I got a few sounds on exit initially, but I think that was down to the size and position of the trigger box which is almost the same size as an NPC. I few adjustments to the box and its fine now.

Thank you again

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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