• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help What's Wrong 2
#1
Hey, I have a problem again :S

The console say :
Code:
script runtime error: potential infinite loop in script - killing thread.
Error: @ 150201

Here is my code :
Code:
GetTargetList()
{
    targets = [];
    if ( level.teamBased )
    {
        if ( IsDefined( level.chopper ) && ( level.chopper.team != self.team || level.chopper.owner == self ) )
            targets[targets.size] = level.chopper;
        if ( isDefined( level.ac130player ) && level.ac130player.team != self.team )
            targets[targets.size] = level.ac130.planemodel;
        if ( isDefined( level.harriers) )
        {
            foreach( harrier in level.harriers )
            {
                if ( isDefined( harrier ) && ( harrier.team != self.team || ( isDefined( harrier.owner ) && harrier.owner == self ) ) )
                    targets[targets.size] = harrier;
            }
        }
        if ( level.UAVModels[level.otherTeam[self.team]].size )
        {
            foreach ( UAV in level.UAVModels[level.otherTeam[self.team]] )
                targets[targets.size] = UAV;
        }
        if ( isDefined( level.littleBird ) )
        {
            foreach ( bird in level.littleBird )
            {
                if ( !isDefined( bird ) )
                    continue;
                if ( self.team != bird.owner.team || self == bird.owner )
                    targets[targets.size] = bird;
            }
        }
    }
    else
    {
        if ( IsDefined( level.chopper ) && ( level.chopper.owner != self ) ) ///check for teams
            targets[targets.size] = level.chopper;
        if ( isDefined( level.ac130player ) )
            targets[targets.size] = level.ac130.planemodel;
        if ( isDefined( level.harriers) )
        {
            foreach( harrier in level.harriers )
            {
                if ( isDefined( harrier ) )
                    targets[targets.size] = harrier;
            }
        }
        if ( level.UAVModels.size )
        {
            foreach ( ownerGuid, UAV in level.UAVModels )
            {
                if ( isDefined( UAV.owner ) && UAV.owner == self )
                    continue;
                targets[targets.size] = UAV;
            }
        }
    }
    return targets;
}

SamFire(Turret)
{
    targets = GetTargetList();
    targetsInReticle = [];
    foreach ( target in targets )
    {
        if ( !isDefined( target ) )
            continue;
        if ( bulletTracePassed( self.origin, target.origin, false, self ) )
            targetsInReticle[targetsInReticle.size] = target;
    }
    sortedTargets = SortByDistance( targetsInReticle, self.origin );
    self.stingerTarget = sortedTargets[0];
    rocket = MagicBullet( "stinger_mp", Turret.origin, self.stingerTarget.origin, self );
    rocket Missile_SetTargetEnt( self.stingerTarget );
    rocket Missile_SetFlightmodeDirect();
}

sentry_burstFireStop(Turret)
{
        self notify( "stop_shooting" );
        Turret LaserOff();
}

SAMTurret()
{
    level endon( "game_ended" );
    team = self.team;
    self endon("disconnect");
    
    self notifyOnPlayerCommand("N", "+actionslot 1");
    self waittill("N");
        Turret = spawnTurret( "misc_turret", self.origin, "pavelow_minigun_mp" );
        Turret setModel( "sentry_minigun" );
        Turret.angles = self.angles;
        Turret SetMode( "auto_ai" );
        Turret SetTurretMinimapVisible( true );
        Turret SetSentryOwner( self );
        Turret setTurretTeam( self.team );
        Turret makeTurretInoperable();
        Turret SetDefaultDropPitch( -25 );
        Turret.team = self.team;
        Turret.owner = self;
        Turret setCanDamage(true);
        
    for(;;)
    {
      if( (level.teambased) && (isDefined(level.chopper)) && (level.chopper.team !=team))
      {
        self thread SamFire(Turret);
        self notify("chopper_down");
        Turret LaserOn();
        self waittill("chopper_down");
        break;
      }
    }
}

Hope someone will try to help me.
Thx for reading.
Dominator56
#2
not sure, is it okay that you have so many if's going in a row?
(sorry if being stupid, I never use anything else but VB.NET)
[Image: r212360a129ce9b84444093b6cd2699013a1fbn155.png]
#3
(02-18-2013, 21:12)G-Man Wrote: not sure, is it okay that you have so many if's going in a row?
(sorry if being stupid, I never use anything else but VB.NET)

I don't think the error is because there are some "if" in a row, but i think it's while and/or for fault
#4
I was thinking about foreach but I cannot be sure, I know the very super uber basics of this language... Hope somebody else can help you Smile
[Image: r212360a129ce9b84444093b6cd2699013a1fbn155.png]
#5
Code:
for(;;)
    {
      if( (level.teambased) && (isDefined(level.chopper)) && (level.chopper.team !=team))
      {
        self thread SamFire(Turret);
        self notify("chopper_down");
        Turret LaserOn();
        self waittill("chopper_down");
        break;
      }
      wait 0.05;
    }

You need to add a wait in that for loop.
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
[-] The following 2 users say Thank You to master131 for this post:
  • Arteq, Dominator56
#6
(02-19-2013, 05:30)master131 Wrote:
Code:
for(;;)
    {
      if( (level.teambased) && (isDefined(level.chopper)) && (level.chopper.team !=team))
      {
        self thread SamFire(Turret);
        self notify("chopper_down");
        Turret LaserOn();
        self waittill("chopper_down");
        break;
      }
      wait 0.05;
    }

You need to add a wait in that for loop.

Thanks you for the help, it works now Wink


Possibly Related Threads...
Thread Author Replies Views Last Post
  Help What's wrong ? Dominator56 4 1,315 02-17-2013, 12:12
Last Post: Dominator56
  I know I've posted this in a wrong place Ra3shed 2 1,031 02-16-2013, 21:15
Last Post: Arteq
Exclamation No site change after 12 rounds... Bug or wrong settings? ChrisPiHD 1 1,080 09-21-2012, 18:16
Last Post: estebespt
  Something wrong with background Arteq 2 1,055 02-27-2012, 17:01
Last Post: Arteq
Question A very, very annoying thing, what is wrong? I don't see it. xplosiff 1 840 12-30-2011, 09:27
Last Post: met94
  lol whats wrong? skata3000 0 797 10-02-2011, 22:35
Last Post: skata3000
  Help What's wrong with this? johamort 8 2,179 08-28-2011, 23:14
Last Post: Tomsen1410
  [Release] Oopz wrong forum JariZ 3 991 07-08-2011, 09:57
Last Post: surtek
  what's wrong with this coding? cervantes 14 2,699 07-04-2011, 07:21
Last Post: tadej
  What's wrong with this script? kikimo900 4 1,021 07-02-2011, 00:19
Last Post: kikimo900

Forum Jump:


Users browsing this thread: 1 Guest(s)