Page 1 of 1

[sp] scripting error

Posted: November 20th, 2006, 12:25 am
by creator
i made a script with in it:
level weapons, stuka, parachute
everything works fine untill stuka ends at end node..
then it says:

Code: Select all

compile error potential infinity loop
plane waittill ("movedone");

Code: Select all

main()
{
maps\_load::main(); 

level.player takeallweapons();
	level.player giveWeapon("sten");
	level.player giveWeapon("colt");
	level.player giveWeapon("fraggrenade");
	level.player switchToWeapon("sten");

thread parachute();
thread plane();
}

parachute()
{
level.player allowProne (false);
level.player allowCrouch (false);

start = level.player.origin;

startheight = start[2];

level.player.origin = level.player.origin + (0,0,0);

parachute = spawn ("script_model",(0,0,0));
parachute setmodel ("xmodel/parachute_animrig");

parachute.origin = level.player.origin;

level.player linkto (parachute,"TAG_player",(0,0,0),(0,0,0));
parachute show();

while (1)
{
wait 0.05;

direction = (0,0,-9);
parachute.origin=parachute.origin+direction;

start = level.player.origin;
end = start + (0,0,-64);

hitcharacters = 1;
results=[];results=bulletTrace(start,end,hitcharacters,level.player);

if (results["fraction"]!=1)
{
level.player.origin = results["position"];
level.player unlink();

level.player allowProne (true);
level.player allowCrouch (true);

break;
}
}
parachute hide();
}

plane() 
{ 
plane = getent ("plane_drop","targetname");
end = getent ("plane_drop_end","targetname");
speed = 6;
while (1) 
{ 
plane moveto(end.origin, speed);
plane waittill ("movedone");
plane delete();
	}
}
i have no idea whats wrong

creator.

Posted: November 20th, 2006, 4:36 pm
by Drofder2004

Code: Select all

plane()
{
plane = getent ("plane_drop","targetname");
end = getent ("plane_drop_end","targetname");
speed = 6;
while (1)
{
plane moveto(end.origin, speed);
plane waittill ("movedone");
plane delete();
   }
}
Read in english...

Find entities plane & end, set speed to 6.
Create infinite loop, move the plane to end location at speed.
When plane has moved, delete the plane.
Move the plane to end origin...
etc..
...


Basically, after you delete the plane, you are then telling the plane to move to a location and wait, but the plane was already deleted and there fore the script is killed.

Try this...

Code: Select all

plane()
{
plane = getent ("plane_drop","targetname");
end = getent ("plane_drop_end","targetname");
speed = 6;

plane moveto(end.origin, speed);
plane waittill ("movedone");
plane delete();
}

Posted: November 20th, 2006, 6:43 pm
by creator
remove while(1) and only 1 or 2 } at end?

Posted: November 20th, 2006, 10:14 pm
by Luke
Erm can't u just try it? If there's 1 open { then you only need 1 } to close it.

Posted: November 20th, 2006, 10:50 pm
by creator
k just tried worked, could not before had some cod problems {again-.-}