Jump to content

[LE] Sending papyrus events from SKSE plugin?


Shakx88

Recommended Posts

I need to create a plugin which will spawn NPCs when something happens in another application. To do so, I decided to use NamedPipes (WinAPI) inside a SKSE plugin. Maybe I'm missing something (since I'm not familiar with Skyrim modding) but I couldn't find a way to spawn NPCs from the plugin. So I decided to try sending events to a papyrus script and handle spawn in the script. This is what I came up with so far (and it doesn't work):

 

Code in SKSE plugin (gets called every time data is sent from another application):

StaticFunctionTag tg;
RawHandleT eventMod = papyrusModEvent::Create(&tg, "MyPluginTestEvent");
papyrusModEvent::Send(&tg, eventMod);

Papyrus script:

Scriptname SpawnHandle extends Quest hidden

event OnInit()
	RegisterForModEvent("MyPluginTestEvent", "OnMyPluginTestEvent")
endevent

event OnPlayerLoadGame()
	RegisterForModEvent("MyPluginTestEvent", "OnMyPluginTestEvent")
endevent

function Init()
	RegisterForModEvent("MyPluginTestEvent", "OnMyPluginTestEvent")
endfunction

Event OnMyPluginTestEvent()
	Debug.MessageBox("Plugin event fired")
	Debug.Notification("Plugin event fired")
endEvent

The script is attached to a quest with following settings:

Type: None;

Priority: 99;

Event: None;

Start Game Enabled;

Allow repeated stages;

One quest stage with one log entry with following settings:

Start Up Stage

Set kmyQuest to the script

PapyrusFragment:

kmyQuest.Init()

What have I done wrong?

 

P.S. And as an additional question: is it possible to spawn NPCs from SKSE plugin (in order to avoid this stuff with events)?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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