Jump to content
DoctaSax

Tutorial: NVSE4+ Part 5: Event Handlers & User-Defined Events (UDEs)

Recommended Posts

Guest tomm434

Another observation:

 

if you SetEvent "OnActivate" without parameters - be prepared that function will be called very often. I travelled from Goodspdings to Primm and player got activated about 20 times. Don't know why but most of the activators was\were "Door", also some NPC.

 

It can be avoided with

if IsControlPressed 5
PrintC "Activate function is triggered via PRESS"
else
PrintC "Activate function is triggered via something else"
endif

But:

 

1)It doesn't work on projectiles (mines) - for some reason when player activates mines "if IsControlPressed 5" returns 0 . However it does work on flora.

2) it can be triggered if player activates (presses "activate" button) something\someone else while another thing\npc activates player.

 

Summary: Don't use this function without the parameters or don't use heavy functions (player can be activated by 20 objects at the same time - it can cause stutter if function is heavy)

 

 

Update1

oops. Wrong.

These "Activations" were not on player. (some NPC from other cells were activated by the door)

 

This line compiles but doesn't work. I'd like to separate activations for player on initial level (so function is not called at all when activated object is not player). Can anything be done?

SetEventHandler "OnActivate" LunetteEVENTFunctionActivate "first"::PlayerRef

Update2

This line works. Looks like  "OnActivate" function for player without second parameter doesn't work.

Right now I want script run when player sits on any furniture and I don't want to make formlist.

 

I think that means that right now I need to specify second parameter or this function will be called on every activation that happens ingame.

SetEventHandler "OnActivate" LunetteEVENTFunctionActivate "first"::LunetteRef
Link to post

About Remove Event Handler

 

From what I understood, I can declare an event without filters (taking all the events of that kind) and then remove those I don't like, filtering them.

But can I remove the same exact event I declared?

the reason is I would like to decide if a event works or not using a boolean on MCM. So in gamemode it will declare the event if it's 1, and it will Remove it if it's 0.

 

Any downside you can see in this?

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...