Killing a script after one use
I have that script:
void main(void)
{
freeze(1);
say_stop("Whoa, i feel dizzy...", 1);
wait(250);
sp_dir(1,2);
wait(100);
sp_dir(1,4);
wait(100);
sp_dir(1,6);
wait(100);
sp_dir(1,8);
wait(100);
say_stop("W...Where am i? Nick?", 1);
wait(200);
sp_dir(1,6);
wait(80);
say_stop("Oh...Oh NO! Nick!", 1);
wait(200);
say_stop("Oh my god! This is not happening, this is NOT happening!", 1);
wait(200);
say_stop("I need to find some cover...and fast!", 1);
unfreeze(1);
}
I need to kill it after this use. But how?
void main(void)
{
freeze(1);
say_stop("Whoa, i feel dizzy...", 1);
wait(250);
sp_dir(1,2);
wait(100);
sp_dir(1,4);
wait(100);
sp_dir(1,6);
wait(100);
sp_dir(1,8);
wait(100);
say_stop("W...Where am i? Nick?", 1);
wait(200);
sp_dir(1,6);
wait(80);
say_stop("Oh...Oh NO! Nick!", 1);
wait(200);
say_stop("Oh my god! This is not happening, this is NOT happening!", 1);
wait(200);
say_stop("I need to find some cover...and fast!", 1);
unfreeze(1);
}
I need to kill it after this use. But how?
You use the kill_this_task(); command to kill a script. This is only needed if the script is not attached to a screen or a sprite. Because if the script is attached to a screen or a sprite the script will be killed automatically once you leave the screen.
I'm very confident that it is killed once you leave the screen. But it sounds like that isn't what you want. You probably want the script not to be run again once you re-enter the screen. Then killing the script is pretty useless...
You need to use a global variable to solve this (for example &story):
void main(void)
{
if (&story == 0)
{
freeze(1);
say_stop("Whoa, i feel dizzy...", 1);
wait(250);
sp_dir(1,2);
wait(100);
sp_dir(1,4);
wait(100);
sp_dir(1,6);
wait(100);
sp_dir(1,8);
wait(100);
say_stop("W...Where am i? Nick?", 1);
wait(200);
sp_dir(1,6);
wait(80);
say_stop("Oh...Oh NO! Nick!", 1);
wait(200);
say_stop("Oh my god! This is not happening, this is NOT happening!", 1);
wait(200);
say_stop("I need to find some cover...and fast!", 1);
unfreeze(1);
&story = 1;
}
}
Check out chapter 8 in my tutorial if you like to know more about making things happen only once.
You need to use a global variable to solve this (for example &story):
void main(void)
{
if (&story == 0)
{
freeze(1);
say_stop("Whoa, i feel dizzy...", 1);
wait(250);
sp_dir(1,2);
wait(100);
sp_dir(1,4);
wait(100);
sp_dir(1,6);
wait(100);
sp_dir(1,8);
wait(100);
say_stop("W...Where am i? Nick?", 1);
wait(200);
sp_dir(1,6);
wait(80);
say_stop("Oh...Oh NO! Nick!", 1);
wait(200);
say_stop("Oh my god! This is not happening, this is NOT happening!", 1);
wait(200);
say_stop("I need to find some cover...and fast!", 1);
unfreeze(1);
&story = 1;
}
}
Check out chapter 8 in my tutorial if you like to know more about making things happen only once.







