📧 Message Board Archive

Why won't this work...
Why doesn't this pause script work?



1. It doesn't stop the midi playing.

2. It doesn't stop timer if there's a one going on. Stop_entire_game(); won't work.



Here's the script:



//Key 80 (P)



void main(void)

{

turn_midi_off();

playsound(52,22050,0,0,0);

show_bmp("graphics\pause.bmp", 0, 0);

playsound(53,22050,0,0,0);

turn_midi_on();

}
Re: Why won't this work...
: Why doesn't this pause script work?



: 1. It doesn't stop the midi playing.



: 2. It doesn't stop timer if there's a one going on. Stop_entire_game(); won't work.



: Here's the script:



: //Key 80 (P)



: void main(void)



: {



: turn_midi_off();



: playsound(52,22050,0,0,0);



: show_bmp("graphics\pause.bmp", 0, 0);



: playsound(53,22050,0,0,0);



: turn_midi_on();



: }



I've never used the "turn_midi_on/off" functions before, but I'd guess that maybe your script is turning the music off, but then, right away, turning it back on.  Try testing this out by making the script wait 5 seconds in between the two functions.  If that works, maybe you could try adding a wait_for_button() type thing to stop the script.



The only real way I know how to stop a midi is to use stopmidi().  I know this sucks, considering you're trying to make a pause button and the script won't know what midi it should start playing. :p



As for stopping a timer (I'm guessing something like the coundown timer in Mystery Island), you'll probably have to add some extra stuff to make sure that works.  Something like killing the timer script if it exists, but saving the current time value somewhere, then when the game is unpaused, the countdown script would be started again with the saved countdown value.