Page 1 of 1
stop or end a thread that you triggered?
Posted: Wed Feb 18, 2004 6:52 am
by small_sumo
How is it done? eg thread mythread then later you want it to stop, how do you stop it? Oh and in this case it is a while(1) looping thread.
Thanks.

end
Posted: Wed Feb 18, 2004 6:59 am
by tltrude
The word "end" makes it stop. You'll have to post it, if you want a better answer.
For a "while" loop, you would put in an "if" statement that, if it is becomes true, will give the command "end" or "break". You would do the same thing for a "goto" loop, but you can not use "break", only "end".
Posted: Wed Feb 18, 2004 7:48 am
by small_sumo
Oh sorry I should have added stop the thread from another thread, thats what I want, a thread is started and later another stread is started and I want it to call for the first thread to stop.
Thanks tltrude.

variable
Posted: Wed Feb 18, 2004 7:55 am
by tltrude
Well have the first thread checking to see if a variable has become true. And, then make it true with the second thread. You have to first define the variable "level.truth = 0".
first_thread:
If (level.truth == 1)
{
end
}
wait 1
goto first_thread
end
second_thread:
Level.truth = 1
end
Can you see how it skips the "end" if it is not true?
What?
Posted: Wed Feb 18, 2004 8:57 am
by Pollo_Expresss
Well I know this is not my post and hope small sumo and tltrude don?t get angry. I have that curiosity. Isn?t the goto first_thread making the script back to the begining and disallowing the second thread to be readed. Well, another noob question. hehhe. Thanks for your patience.
Setthread
Posted: Wed Feb 18, 2004 9:05 am
by tltrude
Normally yes, but you can start the second thread with a trigger in the map. The trigger would have this key/value.
Key: setthread
Value: second_thread
The first thread was probably started the same way form different trigger.
Hope that helps!
Thank you
Posted: Wed Feb 18, 2004 9:23 am
by Pollo_Expresss
Thank you very much, now I understand it, hehehe begining scripting and all all help is grated.
Posted: Wed Feb 18, 2004 11:21 am
by jv_map
1 thing I have to add is there is another method to doing is which I prefer though it is not necessarily a better way and tltrude's way is just fine

.
However, you could do it like this, too:
Code: Select all
first_thread:
thread second_thread
local.second_thread = parm.previousthread
$small_sumo waittill bored
local.second_thread end // or remove / delete
end
second_thread:
while(1)
{
// do stuff ;)
waitframe
}
end
Or, even better:
Code: Select all
first_thread:
thread second_thread
local.second_thread = parm.previousthread
$small_sumo waittill bored
local.second_thread.stopthisthreadnow = 1
end
second_thread:
while(local.stopthisthreadnow != 1)
{
// do stuff ;)
waitframe
}
end
This is basically the same as the method tltrude described, except it now doesn't require a 'level.' variable, which can be an advantage if you require lots of threads like this.
Posted: Wed Feb 18, 2004 2:49 pm
by small_sumo
Okey maybe I shouldnt be so secretive. Here is the code I am working on.
tanks:
// exec global/jv_mp_players.scr::main_player_handler
// $panzer_tankmanspot.origin = $panzer_tankmanspot.origin + ( 0 0 510 )
/*
$panzer_chunk notsolid
$panzer_mg notsolid
$panzer_tankmanspot bind $panzer_chunk
$panzer_tankman glue $panzer_tankmanspot
$panzer_mg_spot bind $panzer_chunk
$panzer_mg glue $panzer_mg_spot
$panzergunnerspot bind $panzer_chunk
$panzer_mg_gunner glue $panzergunnerspot
$panzer_mg tracerFrequency 1
$panzer_chunk glue $panzer
$panzer.health = 700
$panzer.destroyed_model = "models/vehicles/panzer_iv_eud.tik"
$panzer.accuracy = 75
$panzer.shoottime = 0.5
$panzer.firedelay = 1.5
*/
$panzer waitexec global/jv_mp_library.scr::tank_setup
$panzer.turret.targetlist = NULL
$panzer thread targeting
$panzer thread global/jv_mp_library.scr::think
while (level.roundstart != 1)
wait 2
thread driving_miss_daisy // global/jv_mp_library.scr::tank_drive_path $panzerroute 7
wait 1
$panzer_mg exec global/jv_mp_mg42_active_55.scr::mg42 3000
// $panzer thread dontcrushbots
$panzer waittill death
wait 0.5
$panzer_destroyed thread getout
end
driving_miss_daisy:
// thread shoot_at_nothing
while (1)
{
wait 0.1
$panzer thread global/jv_mp_library.scr::tank_drive_path $panzerroute 9
$panzer waittill drive
wait 0.1
}
end
So I plan to stop the miss daisy thread by calling for it to stop in the getout thread.
Btw the mg guy fires away nicly from inside the tank, its very cool.

tank
Posted: Wed Feb 18, 2004 3:59 pm
by tltrude
So, are you saying the tank keeps going after it has been blown up? I don't see how it can finish it's route and start over, if it is dead.
$panzer waittill death
$panzer stop
wait 0.5
$panzer_destroyed thread getout
end
Posted: Wed Feb 18, 2004 5:29 pm
by jv_map
Code: Select all
driving_miss_daisy:
// thread shoot_at_nothing
while (1)
Should be
Code: Select all
driving_miss_daisy:
// thread shoot_at_nothing
while (isAlive $panzer)
Posted: Thu Feb 19, 2004 12:50 am
by small_sumo
Re: tank
Posted: Thu Feb 19, 2004 12:53 am
by small_sumo
tltrude wrote:So, are you saying the tank keeps going after it has been blown up? I don't see how it can finish it's route and start over, if it is dead.
$panzer waittill death
$panzer stop
wait 0.5
$panzer_destroyed thread getout
end
No I get one of those command applied to nil or null something liek that error. Script asks it to drive whn it doesnt exist.
