if then else

Blitz3D Forums/Blitz3D Programming/if then else

Firstly - if musicflag is an integer not a float then it will always be set to zero (as it will round down from 0.5 to 0).

A better way would be to do the following:
At the start of the game set Musicflag to 0.
then do this:
If KeyHit(50)=true then MusicFlag=1-MusicFlag

which will alternate it between 0 and 1 each time it is pressed.
then do this
If MusicFlag=1 then channelvolume PLay_annoy,0.5 else channelvolume Play_annoy,0