Page 1 of 1

Code for fighter

Posted: October 25th, 2011, 11:20 am
by Reality
I have the code for a spacefighter given to me by a friend, all credits goes to him, but the code doesn't seem to work? he had it working because he has video proof! here's the code:

Code: Select all

main()
{
 
        level.spaceFighterHealth = 1000;
        thread constant_gravity();
 
        spacefighter_trigger = getEnt( "spacefighter_trig", "targetname" );
        spacefighter_trig thread waitForPilot();
}
 
waitForPilot()
{
        fighter = getEnt("fighter", "targetname");
        fighter.isSpaceFighter = true;
        fighter thread preFlight();
 
        while(1)
        {
                self waittill("trigger", player);
 
                if(fighter.hasPilot)
                        continue;
 
                if(isDefined(player.isPiloting))
                        continue;
 
                if(player.sessionstate != "playing")
                        continue;
 
                if(!isAlive(player) || !isPlayer(player))
                        continue;
 
                if(isDefined(player.pers["isBot"]))
                        continue;
 
                if(player getStance() == "prone")
                        continue;
 
                fighter.hasPilot = true;
                fighter.owner = player;
                player.isPiloting = true;
                player thread pilotFighter(fighter);
        }
}
The error is something to do with this line:

Code: Select all

spacefighter_trig thread waitForPilot();

Re: Code for fighter

Posted: October 25th, 2011, 3:18 pm
by Drofder2004

Code: Select all

spacefighter_trigger thread waitForPilot();

Re: Code for fighter

Posted: October 25th, 2011, 4:20 pm
by Reality
Drofder2004 wrote:

Code: Select all

spacefighter_trigger thread waitForPilot();
didn't work..

Image

Re: Code for fighter

Posted: October 25th, 2011, 5:16 pm
by Drofder2004
That is either a mapping error (the entity you are trying to reference does not exist) or a scripting erro (the targetname you are asking to find is not correctly spelled).

Re: Code for fighter

Posted: October 25th, 2011, 5:29 pm
by Rezil
Half of your functions seem to be missing(not needed but would help). Also, I'd like to see that video proof.

Re: Code for fighter

Posted: October 25th, 2011, 11:12 pm
by Drofder2004
Rezil wrote:Half of your functions seem to be missing(not needed but would help). Also, I'd like to see that video proof.
I've seen a couple of flight mods (there was the first one, which was posted here a long time ago and was laggy and not very good... but worked and I know there was one used in a Rat Map server.

Re: Code for fighter

Posted: October 25th, 2011, 11:47 pm
by Reality
Rezil wrote:Half of your functions seem to be missing(not needed but would help). Also, I'd like to see that video proof.
Heres the proof.

http://www.xfire.com/video/152a12/
I've seen a couple of flight mods (there was the first one, which was posted here a long time ago and was laggy and not very good... but worked and I know there was one used in a Rat Map server.
He said it was a very simple fix, but he forgot what it was..and we're still trying to figure it out:/

Re: Code for fighter

Posted: October 26th, 2011, 9:52 pm
by Drofder2004
I am pretty sure with the full code it would be easy to figure it out, the error is very specific. Are you sure he wrote the code, or did he get the code off someone else...

The error states the "fighter" is NOT an entity (undefined).

So it can be one of TWO things...

1. fighter = getEnt("fighter", "targetname");
That line is wrong, the entity is not called "fighter" within the map.

2. The map does not contain an entity called "fighter", or it is spelled incorrectly.