Help with Event OnActivate

Post » Mon Jun 18, 2012 9:25 am

Hey guys, I'm hoping you can help me with something;
For a mod I'm making, the player needs to activate a cart to start the quest, and then the cart begins moving. The cart moving works fine, but the problem comes when I try to get the player to enter the cart. Here is my current script that is attached to the cart:
Scriptname ZZCartPassengerScript extends ObjectReference  Idle Property IdleCartPlayerIdle  AutoIdle Property IdleCartDriverExit  AutoEvent OnActivate(ObjectReference akActionRef)function AttachToCart(bool bDoAttach)if bDoAttach; attach me to my cart and make me the driverGame.GetPlayer().SetVehicle(self)Game.GetPlayer().PlayIdle(IdleCartPrisonerCIdle)else; unattach me from cartGame.GetPlayer().SetVehicle(none)Game.GetPlayer().PlayIdle(IdleCartDriverExit)endifendFunctionendEventIdle Property IdleCartPrisonerCIdle  Auto  ObjectReference Property Player  Auto  
The problem is, when I try to compile, I get the following errors:
Starting 1 compile threads for 1 files...Compiling "ZZCartPassengerScript"...f:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\ZZCartPassengerScript.psc(7,0): no viable alternative at input 'function'f:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\ZZCartPassengerScript.psc(18,0): missing EOF at 'endEvent'No output generated for ZZCartPassengerScript, compilation failed.Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on ZZCartPassengerScript

If I comment out both the function, the if, else and endif, and then the part of the script to unattach the player from the cart, when I go ingame and activate, the player mounts the cart fine, but then obviusely can't dismount. Anyone have any ideas?
Thanks :smile:
User avatar
Amanda Leis
 
Posts: 3518
Joined: Sun Dec 24, 2006 1:57 am

Post » Mon Jun 18, 2012 4:00 am

Putting a function inside an event is... odd, to say the least.

Are you sure that's what you want to be doing?
User avatar
Luna Lovegood
 
Posts: 3325
Joined: Thu Sep 14, 2006 6:45 pm

Post » Mon Jun 18, 2012 12:29 pm

I'll be honest, I'm improvising over here :P The thing is, since the player has to activate the cart, I'm assuming I need the Event OnActivate, but I'm not sure what to do with the function :/ Any ideas?
User avatar
gandalf
 
Posts: 3400
Joined: Wed Feb 21, 2007 6:57 pm

Post » Mon Jun 18, 2012 6:38 am

Scriptname ZZCartPassengerScript extends ObjectReferenceIdle Property IdleCartDriverExit  AutoIdle Property IdleCartPrisonerCIdle  AutoBool Property isInCart AutoEvent OnActivate(ObjectReference akActionRef)if isInCart == False	isInCart = True	Game.GetPlayer().SetVehicle(self)	Game.GetPlayer().PlayIdle(IdleCartPrisonerCIdle)Else	isInCart = False	Game.GetPlayer().SetVehicle(none)	Game.GetPlayer().PlayIdle(IdleCartDriverExit)EndIfendEvent

Try that.

I can't guarantee anything, but it SHOULD work.
User avatar
Rhiannon Jones
 
Posts: 3423
Joined: Thu Sep 21, 2006 3:18 pm

Post » Mon Jun 18, 2012 1:46 pm

It works perfectly! Thanks so much! :)
User avatar
Far'ed K.G.h.m
 
Posts: 3464
Joined: Sat Jul 14, 2007 11:03 pm


Return to V - Skyrim