Code for fighter

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
Reality
CJ Newbie
CJ Newbie
Posts: 51
Joined: May 3rd, 2011, 9:57 pm

Code for fighter

Post by Reality » October 25th, 2011, 11:20 am

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();

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Code for fighter

Post by Drofder2004 » October 25th, 2011, 3:18 pm

Code: Select all

spacefighter_trigger thread waitForPilot();
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Reality
CJ Newbie
CJ Newbie
Posts: 51
Joined: May 3rd, 2011, 9:57 pm

Re: Code for fighter

Post by Reality » October 25th, 2011, 4:20 pm

Drofder2004 wrote:

Code: Select all

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

Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Code for fighter

Post by Drofder2004 » October 25th, 2011, 5:16 pm

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).
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Code for fighter

Post by Rezil » October 25th, 2011, 5:29 pm

Half of your functions seem to be missing(not needed but would help). Also, I'd like to see that video proof.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Code for fighter

Post by Drofder2004 » October 25th, 2011, 11:12 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Reality
CJ Newbie
CJ Newbie
Posts: 51
Joined: May 3rd, 2011, 9:57 pm

Re: Code for fighter

Post by Reality » October 25th, 2011, 11:47 pm

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:/

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Code for fighter

Post by Drofder2004 » October 26th, 2011, 9:52 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests