Jump to content

Recommended Posts

Posted

I actually had a very similar question. I am trying to run a script that necessitates a type of "onequip" event, but it needs to store the equipped item and the actor, not just one or the other.

 

So it would be something like: "Event OnHeavyWeaponEquip(Actor akActor, Form akBaseObject). Is this possible? And if so, how would I do it? I've looked at all the custom event creation material, but I still have no idea. I know I can define a custom event, but how to do anything else but define I am completely lost on.

Posted
ScriptName MyModNamespace:PlayerReloadedScript extends ReferenceAlias

; Fields
;---------------------------------------------
; this is the event delegate, it internally manages a list of scripts to invoke when the event is sent.
CustomEvent InitializeEvent


; Methods
;---------------------------------------------

Event OnAliasInit()
	OnPlayerLoadGame()
EndEvent


Event OnPlayerLoadGame()
	Utility.Wait(5.0)
	SendCustomEvent("InitializeEvent") ; send an event whenever the player reloads the game.
EndEvent
ScriptName MyModNamespace:MyScript extends Quest


MyModNamespace:PlayerReloadedScript Property ScriptInstance Auto Const Mandatory
;We need an instance of the script that contains the delegate we want to register on.


; Methods
;---------------------------------------------

Event OnQuestInit()
	If (ScriptInstance)
		RegisterForCustomEvent(ScriptInstance, "InitializeEvent")
	EndIf
EndEvent


Event MyModNamespace:PlayerReloadedScript.InitializeEvent(MyModNamespace:PlayerReloadedScript akSender, var[] arguments)
	Debug.Trace(self + " got the event from " + akSender)
EndEvent

This is a super bad example of an event because theres already plenty of other ways to get the player game reload event. So dont really forward along events that are already available. But I did here to keep it SIMPLE :)

Posted
  On 8/8/2016 at 4:09 AM, scrivener07 said:
ScriptName MyModNamespace:PlayerReloadedScript extends ReferenceAlias

; Fields
;---------------------------------------------
; this is the event delegate, it internally manages a list of scripts to invoke when the event is sent.
CustomEvent InitializeEvent


; Methods
;---------------------------------------------

Event OnAliasInit()
	OnPlayerLoadGame()
EndEvent


Event OnPlayerLoadGame()
	Utility.Wait(5.0)
	SendCustomEvent("InitializeEvent") ; send an event whenever the player reloads the game.
EndEvent
ScriptName MyModNamespace:MyScript extends Quest


MyModNamespace:PlayerReloadedScript Property ScriptInstance Auto Const Mandatory
;We need an instance of the script that contains the delegate we want to register on.


; Methods
;---------------------------------------------

Event OnQuestInit()
	If (ScriptInstance)
		RegisterForCustomEvent(ScriptInstance, "InitializeEvent")
	EndIf
EndEvent


Event MyModNamespace:PlayerReloadedScript.InitializeEvent(MyModNamespace:PlayerReloadedScript akSender, var[] arguments)
	Debug.Trace(self + " got the event from " + akSender)
EndEvent

This is a super bad example of an event because theres already plenty of other ways to get the player game reload event. So dont really forward along events that are already available. But I did here to keep it SIMPLE :smile:

 

 

So as to not hijack someone else's thread, do you mind if I PM with any questions I have?

Posted (edited)

I don't understand.

I'm not sure that's what I ment.

 

Lets work on example:

 

So.. Lets say that I want to create an event:

Event name is "OnPlayerLookBack"

The event triggers whenever player rotates the camera between 160 to 200 degress.

The event must be able to be called in any script by typing "Event OnPlayerLookBack()"

 

How do you do that?

Can you write it here?

Edited by khazerruss
Posted

That is a pretty good example to implement. I dont know off the top of my head how to get the players camera rotation but I have a hunch it can be done with condition functions. One thing about events though is that you should not be able to ever call on them. Only one script should be able to dispatch them and other scripts should register, listen, and then handle the events. I will double post back when I finish the example (if its possible) :)

  • Recently Browsing   0 members

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