Jump to content

Recommended Posts

Posted

Hello,

 

I need to create a script that is attached to an NPC (ObjectReference in the world), which enables the NPC, but only if that NPC is filled by a quest alias.

Once the quest is started, this script could check to see if this Object Reference is filled by the alias, if it is, then it enables it.

 

Any help is greatly appreciated!

 

Plarux

Posted

Quest Property TheQuest Auto Const Mandatory
ReferenceAlias Property Alias_TheNPC Auto Const Mandatory

Event OnInit()
Self.RegisterForRemoteEvent(TheQuest, "OnQuestInit")
EndEvent

Event Quest.OnQuestInit(Quest akSender)
Debug.Trace(Self + " OnQuestInit " + akSender + " Alias_TheNPC " + Alias_TheNPC.GetRef() )
If (Alias_TheNPC.GetRef() == (Self as ObjectReference)) ;make sure quest fill allows disabled
Self.Enable()
EndIf
Self.UnregisterForAllEvents()
EndEvent
Posted (edited)
Quest          Property TheQuest      Auto Const Mandatory
ReferenceAlias Property Alias_TheNPC  Auto Const Mandatory

Event OnInit()
   Self.RegisterForRemoteEvent(TheQuest, "OnQuestInit")
EndEvent

Event Quest.OnQuestInit(Quest akSender)
   Debug.Trace(Self + " OnQuestInit " + akSender + " Alias_TheNPC " + Alias_TheNPC.GetRef() )
   If (Alias_TheNPC.GetRef() == (Self as ObjectReference)) ;make sure quest fill allows disabled 
      Self.Enable() 
   EndIf
   Self.UnregisterForAllEvents()
EndEvent

SKK50, thank you! I will be using this in my bounty mod and make sure to credit you :smile:

 

If I wanted the reference to be disabled once the quest was completed, would I be able to create a new event inside the script that uses OnQuestShutdown, Self.Reset(), and Self.Disable()?

Edited by Plarux
  • Recently Browsing   0 members

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