The Dink Network

Killing a script after one use

April 5th 2009, 06:08 AM
goblinh.gif
mkbul
Peasant He/Him Greece
TPA~ 
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?
April 5th 2009, 07:30 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
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.
April 5th 2009, 07:31 AM
goblinh.gif
mkbul
Peasant He/Him Greece
TPA~ 
It belongs to a screen, but it doesnt get killed!
April 5th 2009, 07:43 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
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.