Problem with script attached to player...

Post » Mon Nov 19, 2012 12:52 am

I want to stop and start a particular quest to refill the quest aliases if the player moves a certain distance away from his starting position. I have done this because I only want the quest aliases to refill when the player moves away from the point where the aliases were filled. So I have attached a script to the player using a second quest that fills its only alias with the player's reference. Both quests are Start Game Enabled but this script is doing nothing-debug message boxes are not showing up in game. It appears as if the OnInit event is not triggering... Any ideas?

Spoiler
Scriptname CQCrimeOverhaulUpdateScript extends Quest  Quest Property CQCrimeOverhaul  Auto  Actor Property PlayerRef AutoImport UtilityImport MathFloat x2_plus_y2Float xFloat yFloat x1Float x2Float y1Float y2Float distance	Event OnInit()	x1=PlayerRef.GetPositionX()		;Gets the player's starting position in the x-y plane.	y1=PlayerRef.GetPositionY()	RegisterForSingleUpdate(1.0)EndEventEvent OnUpdate()	Wait(10.0)	x2=PlayerRef.GetPositionX()		 ;Waits and then gets the player's new position.	y2=PlayerRef.GetPositionY()	x=x1-x2		 ;Calculate the distance between the two points.	x=x*x	y=y1-y2	y=y*y	x2_plus_y2=x+y	distance=sqrt(x2_plus_y2)	if distance>100							 ;If the player has moved over 100 units away from the starting position		CQCrimeOverhaul.Stop()								   ;refresh aliases and set new starting position.		CQCrimeOverhaul.Start()		x1=PlayerRef.GetPositionX()		y1=PlayerRef.GetPositionY()		RegisterForSingleUpdate(1.0)	endIf													RegisterForSingleUpdate(1.0)			 ;Otherwise loop and repeat calculation with new second position.EndEvent
User avatar
sam
 
Posts: 3386
Joined: Sat Jan 27, 2007 2:44 pm

Post » Mon Nov 19, 2012 3:06 pm

Are your aliases set to optional?
User avatar
Mrs Pooh
 
Posts: 3340
Joined: Wed Oct 24, 2007 7:30 pm

Post » Mon Nov 19, 2012 12:46 pm

Yup, the optional box is ticked. I have found that the script works when I attach it to the second quest... I should of just done that in the first place but still... I don't know why what I tried to do initially did not work. Thanks anyway.
User avatar
Andrea Pratt
 
Posts: 3396
Joined: Mon Jul 31, 2006 4:49 am


Return to V - Skyrim

cron