Jump to content

[LE] OnActivate ?


Recommended Posts

Okay I think I have it working...

 

 

 

Event OnActivate(ObjectReference akActionRef)
Debug.notification("You feel a small tingle...")

;do extra stuff here...

while (PlayerRef.GetSitState() != 0)
;Just sit here until they stop using the bench
utility.wait(1)
EndWhile

Debug.notification("The tingling stops...")
;Stop doing extra stuff

EndEvent

 

Link to comment
Share on other sites

You always want to avoid latent functions with while loops, try something more like this:

 

 

Scriptname WC_FurnitureCleanup extends ObjectReference
{Constantly makes sure the furniture is in use before deleting itself. Written by Wilbur Cobb / smashballsx88}

Actor property PlayerRef auto
{Assign this to (any) cell, PlayerRef. This is faster then Game.GetPlayer(), it will be good for looping scripts.}

Event OnInit()
	RegisterForSingleUpdate(4)	;It will begin the check loop in 4 seconds, this makes sure the player finishes entering the furniture before checking.
EndEvent

Event OnUpdate()
	if PlayerRef.GetSitState() != 3	;Checks if the player is still using the furniture. (3 = Sitting)
		self.delete()
	else
		RegisterForSingleUpdate(4)	;Runs the loop every 4 seconds, you can increase this as you see fit.
	endif
endEvent

 

 

 

I gave you this before, you can change around what it does. RegisterForSingleUpdate() Isn't latent, it doesn't hold the script in the memory, it just fires the OnUpdate() event when the timer finishes.

Edited by smashballsx88
Link to comment
Share on other sites

Hmm.... you keep saying you gave me a script before...

sorry I have no recollection of such a script ???

 

So anyway from what you show, to do what I'm after is this correct ?

 

 

 

Scriptname TWEnchantTable extends ObjectReference

Actor Property PlayerRef Auto

Event OnActivate(ObjectReference akActionRef)

Debug.notification("You feel a tingle while using the enchanter...")
;Do my extra stuff here
RegisterForSingleUpdate(4) ;It will begin the check loop in 4 seconds, this makes sure the player finishes entering the furniture before checking.

EndEvent

Event OnUpdate()
if PlayerRef.GetSitState() != 3 ;Checks if the player is still using the furniture. (3 = Sitting)
Debug.notification("The tingling stops...")
;Stop doing extra stuff

else
RegisterForSingleUpdate(2) ;Runs the loop every 2 seconds, you can increase this as you see fit.
endif
endEvent

 

 

 

 

Okay test this and it works... thanks :)

Edited by The-Wanderer
Link to comment
Share on other sites

  • Recently Browsing   0 members

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