Try using dbTimer() to set a cooldown after the inital M press so that it doesn't spam the output of the code.
Using the following code Press M to mute, press M again to unmute:
bool mute = false;
int cooldown = 0;
int thetime = dbTimer();
if (dbKeyState(50) ==1 && mute== false)
{
if ( cooldown < thetime)
{
dbSetMusicVolume (muz,0);
mute=true;
cooldown = thetime + 2000;
}
}
if (dbKeyState(50) ==1 && mute == true)
{
if ( cooldown < thetime)
{
dbSetMusicVolume (muz,100);
mute=false;
cooldown = thetime + 2000;
}
}
That's basically how I do the Skills in my game. =]