Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 99 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 General
General game questions, comments, and chat.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: Is it possible to terminate/kill a thread()
s6robi
General Member
Since: Jun 12, 2006
Posts: 85
Last: Feb 18, 2021
[view latest posts]
Level 3
Category: CoD2 General
Posted: Tuesday, Jan. 26, 2016 08:49 pm
Hello everyone! I am wondering if there is a way to terminate/kill an existing thread()? For example:

Here is my code now:

main()
{
maps\_load::main();
level.allies_accuracy = 10;
level.axis_accuracy = 100;
thread setupplayer();
thread enemy();
thread obj1();
}

setupplayer()
{
level.player takeallweapons();
level.player giveWeapon("mp40");
level.player giveWeapon("luger");
level.player switchToWeapon("mp40");
level.player setViewmodel("xmodel/viewmodel_hands_german" );
}

enemy()
{
guys = getentarray("guy", "targetname");
for(i = 0; i < guys.size; i++)
guys
thread mission_failure();
}

obj1()
{
obj1 = getent("obj1", "targetname");
objective_add(1, "active", &"OASIS_OBJECTIVE_FOLLOW",getent("obj1marker", "targetname").origin);
objective_current(1);

obj1 waittill("trigger");

objective_state(1, "done");
obj1 delete();

thread obj2();
}


obj2()
{


terminate thread(enemy());

obj2 = getent("obj2", "targetname");
objective_add(2, "active", &"OASIS_OBJECTIVE_KILL_SNIPER",getent("obj2", "targetname").origin);
objective_current(2);

obj2 waittill("death");
objective_state(2, "done");
}

mission_failure()
{
self waittill("death");
setCvar("ui_deadquote", "@SCRIPT_MISSION_FAILURE_ALERTED_ENEMY");
maps\_utility::missionFailedWrapper();
}

I want to terminate/kill my "enemy()" thread after i complete the first objective so I can kill the German Soldier without failing the mission.

If anyone knows how this could be done, I would greatly appreciate it!


Thanks!
Share |
Ni3ls
General Member
Since: Nov 7, 2008
Posts: 256
Last: Sep 9, 2017
[view latest posts]
Level 5
Category: CoD2 General
Posted: Wednesday, Jan. 27, 2016 12:07 pm
add "if statement" in the thread.
if(isdefined(level.ending) && level.ending == 1)
return;

add when you are in the last part to the script
level.ending = 1;
Share |
s6robi
General Member
Since: Jun 12, 2006
Posts: 85
Last: Feb 18, 2021
[view latest posts]
Level 3
Category: CoD2 General
Posted: Wednesday, Jan. 27, 2016 02:35 pm
Ni3ls,

Where would I implement that code into my already existing code for it to work? I'm still a little confused. I'm sorry for my confusion.
Share |
Ni3ls
General Member
Since: Nov 7, 2008
Posts: 256
Last: Sep 9, 2017
[view latest posts]
Level 5
Category: CoD2 General
Posted: Wednesday, Jan. 27, 2016 02:44 pm
Well im not sure how your map works.
So correct me.
You are walking in the map. If you shoot somebody, mission is over.
If you walk further you have to kill somebody. If you shoot him, you win.

so in obj2() you have to kill that person to win.
So when you are in that part, let know that you in the final part.

Code:
obj2()
{
level.ending = 1;

obj2 = getent("obj2", "targetname"); 
objective_add(2, "active", &"OASIS_OBJECTIVE_KILL_SNIPER",getent("obj2", "targetname").origin);
objective_current(2); 

Now don't let the mission fail because you kill the objective
Code:
enemy()
{
if(isdefined(level.ending) && level.ending == 1)
return;
guys = getentarray("guy", "targetname");
for(i = 0; i < guys.size; i++)
guys 
thread mission_failure();	
}


Something like that
Share |
s6robi
General Member
Since: Jun 12, 2006
Posts: 85
Last: Feb 18, 2021
[view latest posts]
Level 3
Category: CoD2 General
Posted: Wednesday, Jan. 27, 2016 04:05 pm
attachment: application(2.5Kb)
Ahhh roger that, now I'm tracking.

So, I implimented that code into mine and I got an error saying:

"array is not an object" for self waittill("death");

Attached is my .map file, my .gsc and my .str files and my code is below too. I'm out of ideas on how to get this to work :(

#include maps\_utility;
#include maps\_anim;
#using_animtree("generic_human");


main()
{
maps\_load::main();
level.allies_accuracy = 10;
level.axis_accuracy = 100;
thread setupplayer();
thread enemy();
thread obj1();
}

setupplayer()
{
level.player takeallweapons();
level.player giveWeapon("mp40");
level.player giveWeapon("luger");
level.player switchToWeapon("mp40");
level.player setViewmodel("xmodel/viewmodel_hands_german" );
}

enemy()
{
if(isdefined(level.ending) && level.ending == 1)
return;
guys = getentarray("guy", "targetname");
for(i = 0; i < guys.size; i++)
guys
thread mission_failure();
}

obj1()
{
obj1 = getent("obj1", "targetname");
objective_add(1, "active", &"TESTING_OBJECTIVE_1",getent("obj1marker", "targetname").origin);
objective_current(1);

obj1 waittill("trigger");

objective_state(1, "done");
obj1 delete();

thread obj2();
}


obj2()
{
level.ending = 1;

obj2 = getent("obj2", "targetname");
objective_add(2, "active", &"TESTING_OBJECTIVE_2",getent("obj2", "targetname").origin);
objective_current(2);

obj2 waittill("death");
objective_state(2, "done");
}

mission_failure()
{
self waittill("death");
setCvar("ui_deadquote", "@TESTING_MISSION_FAILURE_ALERTED_ENEMY");
maps\_utility::missionFailedWrapper();
}

Ni3ls, I appreciate your help greatly! You think you'd be able to get this working for me?? This is the last piece of my puzzle to make my SP map awesome! Once I get this up code up and running I will be submitting my SP map to you and the rest of the Modsonline Community.

V/r,
Luke.
Share |
Ni3ls
General Member
Since: Nov 7, 2008
Posts: 256
Last: Sep 9, 2017
[view latest posts]
Level 5
Category: CoD2 General
Posted: Thursday, Jan. 28, 2016 08:33 am
Self (the player?) is not defined here.
Code:
mission_failure()
{
    self waittill("death");
Code:

    for (i = 0; i < guys.size; i++)
        guys thread mission_failure();


Why do you have that waittill("death")?
If you shoot the "guys" mission will be over right?
Share |
s6robi
General Member
Since: Jun 12, 2006
Posts: 85
Last: Feb 18, 2021
[view latest posts]
Level 3
Category: CoD2 General
Posted: Thursday, Jan. 28, 2016 09:15 am
You are correct Ni3ls, I want it to be that if I shoot the "guys" before I complete objective 1 then the mission will fail. I am unsure as to why I had "Waittill("death");" in my code...I obtained that piece of script from another post.

So, I deleted that line of code from my mission_failure() thread, however, When I kill the "Guys" before I reach objective 1 the mission does not end. When I load up the map after two seconds it like almost restarts the map real fast and then allows for play through.

Your thoughts on the matter?? I'm lost now [confused][cry]
Share |
Ni3ls
General Member
Since: Nov 7, 2008
Posts: 256
Last: Sep 9, 2017
[view latest posts]
Level 5
Category: CoD2 General
Posted: Thursday, Jan. 28, 2016 09:28 am
can you compile map for me and make it a working .iwd file?
Share |
s6robi
General Member
Since: Jun 12, 2006
Posts: 85
Last: Feb 18, 2021
[view latest posts]
Level 3
Category: CoD2 General
Posted: Thursday, Jan. 28, 2016 09:40 am
That would be too easy Ni3ls! I'll make the .iwd and include the .map as well. Give me just one moment!
Share |
s6robi
General Member
Since: Jun 12, 2006
Posts: 85
Last: Feb 18, 2021
[view latest posts]
Level 3
Category: CoD2 General
Posted: Thursday, Jan. 28, 2016 10:03 am
attachment: application(17.7Kb)
Ni3ls,

Attached is the testing.zip file containing the .iwd file. Inside the file is the compiled .bsp file, .str, .gsc and .map file.


V/r,
Luke.
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 General

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»