• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [SOLVED] Only play a sound if "SFX Option" is enabled

B

BandiPat

Guest
I've recently finished a simple menu of various options, one being to enable or disable sounds.
When SFX is enabled, I set a vriable "global.sfx" to be 1. If SFX is disabled, it switches to 0. This works perfectly fine.

What I can't seem to figure out is PLAYING the sounds, but only if global.sfx is set to 1. Obviously, the game needs to check if that is the case, and if so, then play the sound, and if not, don't.

So here's what I did (This particular one is for the arrow used to navigate menus):
Code:
if global.sfx = 1
    {
    if sel_u sound_play(sfx_beep);
    if sel_d sound_play(sfx_beep);
    if sel_choose sound_play(sfx_beep);
    }
else if global.sfx = 0
    {
    exit;
    }
And this did absolutely nothing.
Also, yes, "Use New Audio Engine" IS disabled in the global game settings. That's the only way the sounds will play at all on my computer.
 
Last edited by a moderator:
R

renex

Guest
Create this script.
Code:
///splay(soundid)
if (global.sfx) sound_play(argument0)
This way, you can simply replace all calls of sound_play() with splay() and it will handle the check for you.

Now, just a note - don't use exit like that. It will end the current event, and that's probably not what you want to do here.
 
Top