Author |
Topic: looping a script |
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
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 |
|
|
|
hyper1234 |
|
General Member Since: Mar 17, 2009 Posts: 358 Last: Apr 14, 2011 [view latest posts] |
|
|
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 |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
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. |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
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");
}
}
} |
|
|
|
hyper1234 |
|
General Member Since: Mar 17, 2009 Posts: 358 Last: Apr 14, 2011 [view latest posts] |
|
|
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();
}
} |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
|
Uzumakibro93 |
General Member Since: Sep 6, 2009 Posts: 118 Last: Jul 5, 2011 [view latest posts] |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
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. |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
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! [/smile] |
|
|
|