Jump to content

Accessing Event through Quest Script


Recommended Posts

I'm trying to access an event on the player via a quest script, but so far it's not working. The problem is that I haven't got too much experience with papyrus yet, so I don't know what I'm doing wrong. The event I'm trying to access is "OnPlayerUseWorkBench".

 

Here's a piece of the quest script I'm using:

Scriptname MyQuestScript extends Quest

Ammo property AmmoFusionCore auto
ReferenceAlias property Alias_Player auto const mandatory 


Event OnInit()
	Actor PlayerRef = Alias_Player.GetRef() as Actor

	if PlayerRef.GetItemCount(AmmoFusionCore) == 0
		PlayerRef.AddItem(AmmoFusionCore, 1)
	endif
	
	RegisterForRemoteEvent(PlayerRef, "OnPlayerUseWorkBench")
	
EndEvent



Event Actor.OnPlayerUseWorkBench(Actor akSender, ObjectReference akWorkBench)
	Debug.Trace(akWorkBench + " used by " + akSender)
	Debug.Notification("Workbench activated")
	Actor PlayerRef = Alias_Player.GetRef() as Actor
	if akSender == PlayerRef
		Debug.Notification("Player uses " + akWorkBench)
	endif
endEvent

So, when I start the game, the OnInit() is firing. It's giving me an item.

 

So the problem is either with registering the event, or the event itself. How should I do it correctly?

 

Also, I looked up the Event OnPlayerUseWorkBench on the creation kit and it tells me the syntax is OnPlayerUseWorkBench(ObjectReference akWorkBench). But when I used that papyrus threw me an error. But when i changed it to Actor.OnPlayerUseWorkBench(Actor akSender, ObjectReference akWorkBench) it compiled correctly. (I saw the same being done in another quest with an OnDeath() event and copied the same style from there) But can anyone give me a bit more clarification on how that works?

 

Cheers.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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