Thanks.
stop or end a thread that you triggered?
Moderator: Moderators
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
stop or end a thread that you triggered?
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.

Thanks.
end
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".
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".
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
variable
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?
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?
- Pollo_Expresss
- Sergeant
- Posts: 60
- Joined: Thu Jan 08, 2004 12:18 am
- Location: Spain
What?
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
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!
Key: setthread
Value: second_thread
The first thread was probably started the same way form different trigger.
Hope that helps!
- Pollo_Expresss
- Sergeant
- Posts: 60
- Joined: Thu Jan 08, 2004 12:18 am
- Location: Spain
Thank you
Thank you very much, now I understand it, hehehe begining scripting and all all help is grated.
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:
Or, even better:
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.
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
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
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
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.

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
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
$panzer waittill death
$panzer stop
wait 0.5
$panzer_destroyed thread getout
end
Code: Select all
driving_miss_daisy:
// thread shoot_at_nothing
while (1)
Code: Select all
driving_miss_daisy:
// thread shoot_at_nothing
while (isAlive $panzer)
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
Re: tank
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.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



