PeteTheBard Posted July 8, 2015 Share Posted July 8, 2015 Hi people! I am fairly inexperienced at modding and scripting and have been making a mod, I want to ask: - How do I attach a script to a weapon to make that weapon play a sound when the player swings the weapon- What might such a script look like? I've tried using RegisterForAnimationEvent to register for weapon swings, but every time I compile it within my Form script it shows an error saying that it is not a function. I have SKSE installed. I am really confused and would appreciate any input you guys might have, Thank you! P.S: I know that you can add sounds to a weapon directly in the weapon edit screen but I am creating a mod that requires the sound to be played by a script. Link to comment Share on other sites More sharing options...
PeteTheBard Posted July 8, 2015 Author Share Posted July 8, 2015 Ignore me. I meant to say that it hadn't worked with RegisterForActorAction. Tried RegisterForAnimationEvent and the script has actually compiled so I'm off to test it in game. Link to comment Share on other sites More sharing options...
PeteTheBard Posted July 8, 2015 Author Share Posted July 8, 2015 So I solved my problem but in case any others come here from a google search, here is the code I used, which I attached directly to the weapon: Scriptname a_DOVAKHIN extends Form Event OnInit() RegisterForAnimationEvent(Game.GetPlayer(), "weaponSwing") EndEvent Event OnAnimationEvent(ObjectReference akSource, string asEventName) if (akSource == Game.GetPlayer()) && (asEventName == "weaponSwing") int instanceID = Doh1.play(akSource) Sound.SetInstanceVolume(instanceID, 1.0) endIf endEvent Sound Property Doh1 Auto Link to comment Share on other sites More sharing options...
Recommended Posts