Jump to content

Trigger Script only running once


Recommended Posts

Hey guys. I've been trying to work this out but I'm struggling. It feels like a really rookie issue but for some reason, I just can't quite get it to work.

 

I have a script attached to a trigger which disables the player from using weapons. The trigger in inside an interior and runs like a dream the first time. There's another trigger outside the door to re-enable the use of weapons which, again, works perfectly. Only problem is, the script will only run once. When you go back into the interior, it doesn't run and the player is free draw weapons and shoot up the place. How can I make this run indefinitely until the trigger/script is disabled? Script below for disabling and the trigger info.

scn NoDrawInterior

begin ontriggerenter player

DisablePlayerControls 0 0 1 0 0 0

ShowMessage NoWeaponsMessage

end

image.png.6ca169c38f9005f8bcecce4d2e79319e.png

 

...and re-enabling.

scn ReenableWeapons

begin ontriggerenter player

EnablePlayerControls 1 1 1 1 1 1

end

image.png.60f86c36589c0deb5c622bdfbd4dc579.png

 

If anyone can shed any light on this, it'd be much appreciated.

 

Link to comment
Share on other sites

Hey @Pixelhate, thanks for the reply.

Unfortunately, no. I should have mentioned they were ticked as persisent reference before, I turned them off to see if it might help somehow. Just to confirm, I've turned Persistent Reference on both triggers, but unfortunately it still doesn't work after one time.

Link to comment
Share on other sites

Just as a debugging test, try putting your activator outside the building for now. See if walking into it to disable, then walking into your other script to reenable, then returning to the disable trigger works when removing the interior loading up from the equation.

Link to comment
Share on other sites

1 hour ago, sullyvanj93 said:

Just as a debugging test, try putting your activator outside the building for now. See if walking into it to disable, then walking into your other script to reenable, then returning to the disable trigger works when removing the interior loading up from the equation.

Fantastic idea. I've just done that, as seen below.

image.thumb.png.c3f64be20b13de390b57488ec692c4af.png

 

The smaller trigger on the train line is to activate weapons, the big one near the building is to disable... and it works! But what I've noticed is there is a slight delay. If I run into both of them in quick succession, it doesn't seem to work. I know there is sometimes a timer on even if you don't set one, so that might be the issue?

 

Edit: Okay I think it might be fixed! Not quite the fix I was looking for but it works and that's all that matters.

I think the issue was the game was trying to run both scripts so quickly, it was cancelling it out. You have to walk through the weapons enable trigger to get inside, and since you immediately spawn inside the trigger, I assume it was just ignoring it, since it was already running one.

image.thumb.png.32d10b1eacf53ef7d623ec7d75fc0bf6.png

What I've done is move the trigger in and place a wall, so the player won't be able to see around it until the script kicks in. I've only tried it 3-4 times but it's worked every time since. @sullyvanj93 and @Pixelhate I really want to thank you both for helping.

Link to comment
Share on other sites

That's great to hear it's working well for you with your workaround!

If the processing delay is a bit too slow for you (I don't know the default for an object script, like for an activator), you might be able to convert the script and variables into a quest script, where you can change the processing delay to something a bit quicker. Or add a condition for the script to undo itself upon exiting your interior, rather than having a second "reenable" trigger. Perhaps take a look at what they do in places like the Fort or other vanilla instances and try to reverse engineer those. 

But if your workaround is working well enough for you to be content, definitely consider that a win! Sometimes we really have to trick this game into doing what it's supposed to 😉 

Link to comment
Share on other sites

I've been working on this same project for a while and I think one of the bigger reasons this wasn't working very well is my script was a MESS. I had hardly anything in the quest script itself and a lot of it was in dialogu begin/ends. Which is fine when you're only running a few things but eventually I was adding more and more and it just seems to be too much. Now I've cleaned up a bit and actually removed the trigger in the building completely, like you suggested.. For anyone who might have stumbled across this thread and wanted to know how to disable weapons in specific areas, I've upgraded to this very simple script.

if player.getincell CellID ==1
    DisablePlayerControls 0 0 1 0 0 0
    ShowMessage NoWeaponsMessage

Then I just have a trigger on the door outside to make sure controls are able to be used once you leave. I opted for that over a script so it won't override any other script that tries to disable controls when roaming around the wasteland. I will definitely look into other places that disable weapons. Thanks again!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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