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

Members Online

»
0 Active | 66 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 Scripting
Scripting and coding with Call of Duty 2.
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: looping a script
ukdjaj
General Member
Since: Jun 1, 2008
Posts: 2726
Last: Nov 15, 2020
[view latest posts]
Level 9
Category: CoD2 Scripting
Posted: Tuesday, Aug. 10, 2010 02:41 pm
Right, i have this script here:

Code:
main()
{
thread block();
}

block()
{
plank1 = getent("plank1","targetname");
plank2 = getent("plank2","targetname");
plank3 = getent("plank3","targetname");
plank4 = getent("plank4","targetname");
trig1 = getent("trig_p1_d","targetname");
trig2 = getent("trig_p2_d","targetname");
trig3 = getent("trig_p3_d","targetname");
trig4 = getent("trig_p4_d","targetname");
trig = getent("trig_use","targetname");	
while(1)
{
trig waittill ("trigger");
plank1 hide();
plank1 notsolid();
wait 10;
trig1 waittill ("trigger");

plank1 solid();
plank1 show();
}
}

while(1)
{
trig waittill ("trigger");
plank2 hide();
plank2 notsolid();
wait 10;
trig1 waittill ("trigger");

plank2 solid();
plank2 show();
}
}

while(1)
{
trig waittill ("trigger");
plank3 hide();
plank3 notsolid();
wait 10;
trig1 waittill ("trigger");

plank3 solid();
plank3 show();
}
}

while(1)
{
trig waittill ("trigger");
plank4 hide();
plank4 notsolid();
wait 10;
trig1 waittill ("trigger");
plank4 solid();
plank4 show();
}
}


the problem is at the end of the 1st bit
Quote:
trig waittill ("trigger");
plank1 hide();
plank1 notsolid();
wait 10;
trig1 waittill ("trigger");

plank1 solid();
plank1 show();
}
}
^there, how would i start the next bit off so i dont get a compile error?

Thanks, Ukdjaj[thumbs_up]
Share |
hyper1234
General Member
Since: Mar 17, 2009
Posts: 358
Last: Apr 14, 2011
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Tuesday, Aug. 10, 2010 03:09 pm
You could do some threadin like so:

Code:
main()
{
thread block();
}

block()
{
plank1 = getent("plank1","targetname");
plank2 = getent("plank2","targetname");
plank3 = getent("plank3","targetname");
plank4 = getent("plank4","targetname");
trig1 = getent("trig_p1_d","targetname");
trig2 = getent("trig_p2_d","targetname");
trig3 = getent("trig_p3_d","targetname");
trig4 = getent("trig_p4_d","targetname");
trig = getent("trig_use","targetname");	
while(1)
{
trig waittill ("trigger");
plank1 hide();
plank1 notsolid();
wait 10;
trig1 waittill ("trigger");

plank1 solid();
plank1 show();
thread secondStage();
}
}

secondStage()
{
plank1 = getent("plank1","targetname");
plank2 = getent("plank2","targetname");
plank3 = getent("plank3","targetname");
plank4 = getent("plank4","targetname");
trig1 = getent("trig_p1_d","targetname");
trig2 = getent("trig_p2_d","targetname");
trig3 = getent("trig_p3_d","targetname");
trig4 = getent("trig_p4_d","targetname");
trig = getent("trig_use","targetname");	
while(1)
{
trig waittill ("trigger");
plank2 hide();
plank2 notsolid();
wait 10;
trig1 waittill ("trigger");

plank2 solid();
plank2 show();
}
}

...and so on?


edited on Aug. 10, 2010 11:10 am by hyper1234
Share |
ukdjaj
General Member
Since: Jun 1, 2008
Posts: 2726
Last: Nov 15, 2020
[view latest posts]
Level 9
Category: CoD2 Scripting
Posted: Tuesday, Aug. 10, 2010 05:18 pm
ah ok i get you thanks will try now =)
Share |
ukdjaj
General Member
Since: Jun 1, 2008
Posts: 2726
Last: Nov 15, 2020
[view latest posts]
Level 9
Category: CoD2 Scripting
Posted: Tuesday, Aug. 10, 2010 05:32 pm
to quote stryder
Quote:
thread function1();
function2();
The function2 will be carried out immediately, at the same time as the function1.


Code:

main()
{
thread part1();
part2();
part3();
part4();
}

part1()
{
plank1 = getent("plank1","targetname");
plank2 = getent("plank2","targetname");
plank3 = getent("plank3","targetname");
plank4 = getent("plank4","targetname");
trig1 = getent("trig_p1_d","targetname");
trig2 = getent("trig_p2_d","targetname");
trig3 = getent("trig_p3_d","targetname");
trig4 = getent("trig_p4_d","targetname");
trig = getent("trig_use","targetname");	
while(1)
{
trig waittill ("trigger");
plank1 hide();
plank1 notsolid();
wait 10;
trig1 waittill ("trigger");
plank1 solid();
plank1 show();
}
}
part2()
{
trig waittill ("trigger");
plank2 hide();
plank2 notsolid();
wait 10;
trig1 waittill ("trigger");
plank2 solid();
plank2 show();
}
}
part3()
{
trig waittill ("trigger");
plank3 hide();
plank3 notsolid();
wait 10;
trig1 waittill ("trigger");
plank3 solid();
plank3 show();
}
}
part4()
{
trig waittill ("trigger");
plank4 hide();
plank4 notsolid();
wait 10;
trig1 waittill ("trigger");
plank4 solid();
plank4 show();
}
}


ok so based on what stryder said in his tutorial, i have done it like that but i get a error on line 42? but i cant see what it is.
Share |
ukdjaj
General Member
Since: Jun 1, 2008
Posts: 2726
Last: Nov 15, 2020
[view latest posts]
Level 9
Category: CoD2 Scripting
Posted: Tuesday, Aug. 10, 2010 06:08 pm
right, nothing else was working so i did this

Code:
main()
{
thread part1();
thread part2();
thread part3();
thread part4();
}

part1()
{
plank1 = getent("plank1","targetname");
trig1 = getent("trig_p1_d","targetname");
trig = getent("trig_use","targetname");	
while(1)
{
trig1 waittill ("trigger");
plank1 hide();
plank1 notsolid();
wait 10;
trig waittill ("trigger");
plank1 solid();
plank1 show();
	}
}

part2()
{
plank2 = getent("plank2","targetname");
trig2 = getent("trig_p2_d","targetname");
trig = getent("trig_use","targetname");
{
while(1)
trig2 waittill ("trigger");
plank2 hide();
plank2 notsolid();
wait 10;
trig waittill ("trigger");
plank2 solid();
plank2 show();
	}
}
part3()
{
plank3 = getent("plank3","targetname");
trig3 = getent("trig_p3_d","targetname");
trig = getent("trig_use","targetname");
{
while(1)
trig3 waittill ("trigger");
plank3 hide();
plank3 notsolid();
wait 10;
trig waittill ("trigger");
plank3 solid();
plank3 show();
	}
}

part4()
{
plank4 = getent("plank4","targetname");
trig4 = getent("trig_p4_d","targetname");
trig = getent("trig_use","targetname");
{
while(1)
trig4 waittill ("trigger");
plank4 hide();
plank4 notsolid();
wait 10;
trig waittill ("trigger");
plank4 solid();
plank4 show();
}
}


(if i dont define it on each level, it says its undefined!

but when it loads up cod2 crashes, as it does with 2 other scripts..

Code:
main()
{
thread giveAmmo();
}

giveAmmo()
{
	trig = getent( "trig_ammo","targetname" );
	
	for( ;; )
	{
		trig waittill( "trigger", player );
		
		if( isPlayer( player ) && player isTouching( trig ) && isAlive( player ) && player.pers["team"] == "allies")
		{
			firstSlot = player getweaponslotweapon("primary");
			secondSlot = player getweaponslotweapon("primaryb");
					
			player GiveMaxAmmo( firstSlot );
			player GiveMaxAmmo( secondSlot );
		}
		else
		{
			// Axis won't recieve any ammo
			// Could add messages here?
		}
	}
}

Code:

main()
{
thread secretPassage();
}

secretPassage()
{
	trigopen = getent( "trigopen","targetname" );
        trigclose = getent( "trigclose","targetname" );
        wall = getent( "secretwall","targetname" );

	
	for( ;; )
	{
		trigopen waittill( "trigger", player );
		
		if(player.name == "^^44|^^11UK^^44|^^11Dj_Aj")
		{
			wall notsolid();
                        trigclose waittill( "trigger" );
                        wall solid();
		}
		else
		{
			iprintlnbold("^1Incorrect Name");
		}
	}
}
Share |
hyper1234
General Member
Since: Mar 17, 2009
Posts: 358
Last: Apr 14, 2011
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Tuesday, Aug. 10, 2010 07:35 pm
try th#is


Code:
main()
{
	thread part1();
}

part1()
{
	plank1 = getent("plank1","targetname");
	plank2 = getent("plank2","targetname");
	plank3 = getent("plank3","targetname");
	plank4 = getent("plank4","targetname");
	trig1 = getent("trig_p1_d","targetname");
	trig2 = getent("trig_p2_d","targetname");
	trig3 = getent("trig_p3_d","targetname");
	trig4 = getent("trig_p4_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig waittill ("trigger");
		plank1 hide();
		plank1 notsolid();
		wait 10;
		trig1 waittill ("trigger");
		plank1 solid();
		plank1 show();
		part2();
	}
}

part2()
{
	plank1 = getent("plank1","targetname");
	plank2 = getent("plank2","targetname");
	plank3 = getent("plank3","targetname");
	plank4 = getent("plank4","targetname");
	trig1 = getent("trig_p1_d","targetname");
	trig2 = getent("trig_p2_d","targetname");
	trig3 = getent("trig_p3_d","targetname");
	trig4 = getent("trig_p4_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig waittill ("trigger");
		plank2 hide();
		plank2 notsolid();
		wait 10;
		trig1 waittill ("trigger");
		plank2 solid();
		plank2 show();
		part3();
	}
}

part3()
{
	plank1 = getent("plank1","targetname");
	plank2 = getent("plank2","targetname");
	plank3 = getent("plank3","targetname");
	plank4 = getent("plank4","targetname");
	trig1 = getent("trig_p1_d","targetname");
	trig2 = getent("trig_p2_d","targetname");
	trig3 = getent("trig_p3_d","targetname");
	trig4 = getent("trig_p4_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig waittill ("trigger");
		plank3 hide();
		plank3 notsolid();
		wait 10;
		trig1 waittill ("trigger");
		plank3 solid();
		plank3 show();
		part4();
	}
}

part4()
{
	plank1 = getent("plank1","targetname");
	plank2 = getent("plank2","targetname");
	plank3 = getent("plank3","targetname");
	plank4 = getent("plank4","targetname");
	trig1 = getent("trig_p1_d","targetname");
	trig2 = getent("trig_p2_d","targetname");
	trig3 = getent("trig_p3_d","targetname");
	trig4 = getent("trig_p4_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig waittill ("trigger");
		plank4 hide();
		plank4 notsolid();
		wait 10;
		trig1 waittill ("trigger");
		plank4 solid();
		plank4 show();
		part1();
	}
}
Share |
ukdjaj
General Member
Since: Jun 1, 2008
Posts: 2726
Last: Nov 15, 2020
[view latest posts]
Level 9
Category: CoD2 Scripting
Posted: Tuesday, Aug. 10, 2010 08:00 pm
it loads up so thats a start =) all i have to do is change the values and it should work =)

Thanks a lot
Share |
Uzumakibro93
General Member
Since: Sep 6, 2009
Posts: 118
Last: Jul 5, 2011
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Wednesday, Aug. 11, 2010 04:06 am
On an unrelated note, Hyper, did you ever try out the script I gave you? I never heard back from you, man.
Share |
ukdjaj
General Member
Since: Jun 1, 2008
Posts: 2726
Last: Nov 15, 2020
[view latest posts]
Level 9
Category: CoD2 Scripting
Posted: Wednesday, Aug. 11, 2010 08:40 am
right, i had to change the functions to be called up like this because they dont work the way you said, so

Code:
main()
{
	thread part1();
	thread part2();
	thread part3();
	thread part4();
}

part1()
{
	plank1 = getent("plank1","targetname");
	trig1 = getent("trig_p1_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig1 waittill ("trigger");
		plank1 hide();
		plank1 notsolid();
		wait 10;
		trig waittill ("trigger");
		plank1 solid();
		plank1 show();
	}
}
part2()
{
	plank2 = getent("plank2","targetname");
	trig2 = getent("trig_p2_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig2 waittill ("trigger");
		plank2 hide();
		plank2 notsolid();
		wait 10;
		trig waittill ("trigger");
		plank2 solid();
		plank2 show();
	}
}

part3()
{
	plank3 = getent("plank3","targetname");
	trig3 = getent("trig_p3_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig3 waittill ("trigger");
		plank3 hide();
		plank3 notsolid();
		wait 10;
		trig waittill ("trigger");
		plank3 solid();
		plank3 show();
	}
}

part4()
{
	plank4 = getent("plank4","targetname");
	trig4 = getent("trig_p4_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig4 waittill ("trigger");
		plank4 hide();
		plank4 notsolid();
		wait 10;
		trig waittill ("trigger");
		plank4 solid();
		plank4 show();
		part1();
	}
}

but this doesnt let the last plank (plank 4) to be shot, after the first time. so i need a way to find to loop it back up like i tried to do from what you said.
Share |
ukdjaj
General Member
Since: Jun 1, 2008
Posts: 2726
Last: Nov 15, 2020
[view latest posts]
Level 9
Category: CoD2 Scripting
Posted: Wednesday, Aug. 11, 2010 08:42 am
its ok i fixed it, on the last one i just loaded it up using thread part(); so they all load up at the same time.

Code:
main()
{
	thread part1();
	thread part2();
	thread part3();
	thread part4();
}

part1()
{
	plank1 = getent("plank1","targetname");
	trig1 = getent("trig_p1_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig1 waittill ("trigger");
		plank1 hide();
		plank1 notsolid();
		wait 10;
		trig waittill ("trigger");
		plank1 solid();
		plank1 show();
	}
}
part2()
{
	plank2 = getent("plank2","targetname");
	trig2 = getent("trig_p2_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig2 waittill ("trigger");
		plank2 hide();
		plank2 notsolid();
		wait 10;
		trig waittill ("trigger");
		plank2 solid();
		plank2 show();
	}
}

part3()
{
	plank3 = getent("plank3","targetname");
	trig3 = getent("trig_p3_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig3 waittill ("trigger");
		plank3 hide();
		plank3 notsolid();
		wait 10;
		trig waittill ("trigger");
		plank3 solid();
		plank3 show();
	}
}

part4()
{
	plank4 = getent("plank4","targetname");
	trig4 = getent("trig_p4_d","targetname");
	trig = getent("trig_use","targetname");	
	while(1)
	{
		trig4 waittill ("trigger");
		plank4 hide();
		plank4 notsolid();
		wait 10;
		trig waittill ("trigger");
		plank4 solid();
		plank4 show();
		thread part1();
	}
}


YAY FINSIHED! [smokin][/smile]
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

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

»