stop or end a thread that you triggered?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
small_sumo
Lieutenant General
Posts: 953
Joined: Mon Jul 01, 2002 4:17 pm
Contact:

stop or end a thread that you triggered?

Post 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.

:)
Image

www.smallsumo.tk

Yeah Truth above Honor Man ;)
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

end

Post 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".
Tom Trude,

Image
User avatar
small_sumo
Lieutenant General
Posts: 953
Joined: Mon Jul 01, 2002 4:17 pm
Contact:

Post 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.

:)
Image

www.smallsumo.tk

Yeah Truth above Honor Man ;)
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

variable

Post 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?
Tom Trude,

Image
User avatar
Pollo_Expresss
Sergeant
Posts: 60
Joined: Thu Jan 08, 2004 12:18 am
Location: Spain

What?

Post 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.
*(ICE)*-Sd_Pollo_Expresss
http://www.iceclanweb.net

Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Setthread

Post 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!
Tom Trude,

Image
User avatar
Pollo_Expresss
Sergeant
Posts: 60
Joined: Thu Jan 08, 2004 12:18 am
Location: Spain

Thank you

Post by Pollo_Expresss »

Thank you very much, now I understand it, hehehe begining scripting and all all help is grated.
*(ICE)*-Sd_Pollo_Expresss
http://www.iceclanweb.net

Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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.
Image
User avatar
small_sumo
Lieutenant General
Posts: 953
Joined: Mon Jul 01, 2002 4:17 pm
Contact:

Post 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.

;)
Image

www.smallsumo.tk

Yeah Truth above Honor Man ;)
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

tank

Post 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
Tom Trude,

Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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) 
Image
User avatar
small_sumo
Lieutenant General
Posts: 953
Joined: Mon Jul 01, 2002 4:17 pm
Contact:

Post by small_sumo »

:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:
:oops: :oops: :oops: :oops: :oops: :oops: :oops:


oh well at least I learned soemthing, thanks tltrude and jv.

Bye

:)
Image

www.smallsumo.tk

Yeah Truth above Honor Man ;)
User avatar
small_sumo
Lieutenant General
Posts: 953
Joined: Mon Jul 01, 2002 4:17 pm
Contact:

Re: tank

Post 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.

:(
Image

www.smallsumo.tk

Yeah Truth above Honor Man ;)
Post Reply