Papyrus - Play Sound

Post » Tue Jun 19, 2012 11:00 pm

I'm trying to use this, seemingly simple, event:

http://www.creationkit.com/Play_-_Sound

But not being a 'coder' kind of person, I'm hitting a wall and I'm hoping someone can enlighten me.

The Syntax:

int Function Play(ObjectReference akSource) native

Is meant to go into the header before any events fire?

and the example they give goes into an event? :

int instanceID = mySFX.play(self)		  ; play mySFX sound from my selfSound.SetInstanceVolume(instanceID, 0.5)		 ; play at half volume


So far it just throws me a 'variable mySFX is undefined. Which makes sense since it isn't defined - but where does it get defined in the header? Is it part of that Syntax line? the 'int Function play' part I've changed to 'int myFuncName play' and mySFX into myFuncName but that doesn't do anything and more importantly, where do I reference the actual sound file to play?
User avatar
Calum Campbell
 
Posts: 3574
Joined: Tue Jul 10, 2007 7:55 am

Post » Tue Jun 19, 2012 11:42 pm

Sound Property yoursoundhere auto

yoursoundhere.Play

I think.
User avatar
Lucky Boy
 
Posts: 3378
Joined: Wed Jun 06, 2007 6:26 pm

Post » Wed Jun 20, 2012 2:45 am

You need to declare a sound property called mySFX and set the value to the sound you want. In the example, the source is the object on wich the script is attached, but it can be any reference. It's the source of the sound.

There is already a script that play a sound at a select source : DefaultPlaySoundAtLinkSCRIPT
User avatar
Allison Sizemore
 
Posts: 3492
Joined: Wed Jul 19, 2006 6:09 am

Post » Wed Jun 20, 2012 3:17 am

Nevermind, try this instead :

yoursoundhere.Play(Game.GetPlayer())
User avatar
Wanda Maximoff
 
Posts: 3493
Joined: Mon Jun 12, 2006 7:05 am

Post » Tue Jun 19, 2012 8:59 pm

I've tried the DefaultPlaySoundAtLinkSCRIPT but that didn't work for some reason - nothing would play. I've even tried just a dead simple:
Sound Property MAGVampireSunlightSD Auto>>>>MAGVampireSunlightSD.Play(Self)

But still nothing would play. I'm trying to add a sound effect when an item is equipped but maybe it's being prioritized lower by the default sound effect of equiping/unequiping and item?
User avatar
Dan Scott
 
Posts: 3373
Joined: Sun Nov 11, 2007 3:45 am

Post » Wed Jun 20, 2012 10:06 am

I don't have the CK on this computer so I'm going by memory but doesn't most weapons/items have a property/setting in the CK for this exact thing?
Is it the "Pickup sound" and "Putdown sound"? Or is that for something else?
User avatar
Leilene Nessel
 
Posts: 3428
Joined: Sun Apr 15, 2007 2:11 am

Post » Tue Jun 19, 2012 8:23 pm

I saw that but I just assumed it was a literal 'pick up' and 'put down' - does it also mean 'equip' and 'unequip'? I'll try it.
User avatar
james tait
 
Posts: 3385
Joined: Fri Jun 22, 2007 6:26 pm

Post » Tue Jun 19, 2012 8:52 pm

You cannot play a sound descriptor, like xxxxxSD. You must use the sound MAGVampireSunlight.
User avatar
glot
 
Posts: 3297
Joined: Mon Jul 17, 2006 1:41 pm

Post » Wed Jun 20, 2012 3:58 am

I did try with ID version - the SD version above was a hold over from my next attempt.
User avatar
Jack Walker
 
Posts: 3457
Joined: Wed Jun 06, 2007 6:25 pm

Post » Wed Jun 20, 2012 1:15 am

You didn't set the volume.

int instanceID = mySFX.play(self)		  ; play mySFX sound from my selfSound.SetInstanceVolume(instanceID, 0.5)		 ; play at half volume


Edit : and don't forget that the sound must be loaded before it can be played and heared. It can take some time if you COC and make the test immediately. Wait 10 seconds before testing after loading your cell.
User avatar
Ridhwan Hemsome
 
Posts: 3501
Joined: Sun May 06, 2007 2:13 pm

Post » Wed Jun 20, 2012 7:04 am

Got it working as good as it gets with the 'pick up' and 'put down' audio. Thanks guys.
User avatar
Robert
 
Posts: 3394
Joined: Sun Sep 02, 2007 5:58 am


Return to V - Skyrim