Author Topic: Unable to play sound in code  (Read 3531 times)

So I'm sitting here trying to get the sound to work to play through alxPlay. I've tried renaming the function, varaibles, everything. It used to work, but now it won't do anything. This is what I got:
Code: [Select]
function SFXPlay(%audiodescription, %zipname, %filename)
{
     if(isFile(""@ $TCcoreSFX::Path @ "sfx_"@ %filename @ ".wav"))
     {
          if(alxIsPlaying($client::SFXIsPlaying))
               alxStop($client::SFXIsPlaying);
          $client::SFXIsPlaying = alxCreateSource(%audiodescription, ""@ $TCcoreSFX::Path @ "sfx_"@ %filename @ ".wav", %client.obj);
          alxPlay($client::SFXIsPlaying);
     }

(Its pretty much the same, but it looks for a alternate using %zipname, and %filename within the addon folder for the sound, making it so other coders can create their own addon using this addon basically. Straight forward and simple.)
« Last Edit: January 02, 2015, 10:44:46 PM by Quinn Mallory »

Have you verified that it passes the isFile check?

I checked and see if its set on the right path. It uses it through the sound addons. Making it accessible in the event system. And made sure it was spelled like the way I spelled it.

Have you verified that it passes the isFile check?

Do you need to look at the file I got?

Just put an echo in after the isFile check.

Just put an echo in after the isFile check.

I just did. Its not passing the isFile check somehow. This is a strange bug I encountered. I'm just going to post a direct rip of the variables, and the code I used.

Code: [Select]
$TCcoreSFX::Path = "Add-Ons/Sound_TCcoreSounds/";
        function SFXPlay(%audiodescription, %zipname, %filename)
{
if(isFile(""@ $TCcoreSFX::Path @ "sfx_"@ %filename @ ".wav"))
{
echo("[Time Controls Core] says: Pre-check complete. "@ %filename @ " exists. Playing sound...");
if(alxIsPlaying($client::SFXIsPlaying))
echo("[Time Controls Core] says: A sound is already playing. Stopping...");
alxStop($client::SFXIsPlaying);
$client::SFXIsPlaying = alxCreateSource(%audiodescription, ""@ $TCcoreSFX::Path @ "sfx_"@ %filename @ ".wav", %client.obj);
alxPlay($client::SFXIsPlaying);
}
if(isFile("Add-Ons/TimeControlSound_"@ %zipname @ "sfx_"@ %filename @ ".wav"))
{
if(alxIsPlaying($client::SFXIsPlaying))
alxStop($client::SFXIsPlaying);
$client::SFXIsPlaying = alxCreateSource(%audiodescription, "Add-Ons/TimeControlSound_"@ %zipname @ "sfx_"@ %filename @ ".wav", %client.obj);
alxPlay($client::SFXIsPlaying);
}
}

Does it have to include the .zip in the variable?
EDIT: Nvm, I tried it. Still doesnt pass. Blockland sees it in the event system, and plays fine.
« Last Edit: January 03, 2015, 06:06:43 PM by Quinn Mallory »

I got smart and did it in the console. I need to make it as a audio profile, not description. Thanks for your replies anyways... lol...

Code: [Select]
if(alxIsPlaying($client::SFXIsPlaying))
echo("[Time Controls Core] says: A sound is already playing. Stopping...");
alxStop($client::SFXIsPlaying);

This will not work as intended. If you want more than one statement within an if, you need braces {  } .

Tried with {}'s, still didnt play the sound.

You're trying to play sounds from a .zip file right?


Have you discovered the file?

I've also heard it has issues using alx functions with zip files.

Have you discovered the file?

I've also heard it has issues using alx functions with zip files.

I solved it. I thought it was just using a audio descriptions instead of audio profiles.