Game Development Community

Syntax error in function

by Mike Rowley · in Torque Game Engine · 06/23/2006 (5:49 pm) · 6 replies

I'm modding my game to use the realmwars select screen. I have all the files, all exec'd, all working eccept 1.
I'm getting the following error in the console log, and I don't understand it. Everything looks correct.

Quote:
server/scripts/gameTypes/baseGame.cs Line: 233 - Syntax error.
line
233 function serverCmdspawnPlayer(%client,%team,%model)
234 {
235    echo ("got a server command to spawn a player\n");
236    %client.spawnPlayer(%team,%model);
237 }

Becouse of this error, baseGame.cs isnt compiling, and the game gets stuck here becouse after this function is the spawn point functions.
Any help will be appreciated.
I'm still learning programming.

#1
06/24/2006 (5:13 am)
I don't think it would matter but check that space between echo and your first '('. Otherwise I can't see any issue. I know it says line 233, but sometimes debuggers give strange line numbers.
#2
06/24/2006 (5:50 am)
@Rick:
Quote:
don't think it would matter but check that space between echo and your first '('.

It doesn't matter. Some programmers even prefer to type it that way because it looks cleaner to them.

@Mike:
There's nothing wrong with the code you posted.

The problem lies on the line before 233, that's where you got your syntax error. The compiler just halts at 233 because it expected it to look different based on what the line before it looked like.

Edit:

Let me examplify:

1  echo("Syntax error here")
2
3  function helloWorld()
4  {
5      echo("Hello World!");
6  }

Running the above code would give you a syntax error on line 3. But the actual syntax error is on line 1. There's no semicolon at the end of line 1 which screws the compiler.
#3
06/24/2006 (9:38 am)
Stefan is absolutely correct--the error is above the code listed for the reasons Stefan said.

Most probably, you are missing a closing }, or possibly ) in your preceding code.
#4
06/24/2006 (4:06 pm)
Thankyou. I've run across this same error a bunch of times and just ended up removing the function, or starting over becouse I couldn't figure out what the problem was.
Now I know where to look. :)
#5
06/24/2006 (4:20 pm)
The line the error is reported on is simply that. It doesn't always mean there is a syntax error on that line, just where it was detected. so it's always a good idea to look above and below that line.

Chances are you're missing a semicolon or something on the line above.
#6
06/24/2006 (8:00 pm)
Thanks. Got that error nixed. :) (dummy me deleted a } )