Author Topic: Error - Adding variables to a message. More errors!  (Read 2549 times)

This is what the blockland bug-finding thing says:
Code: [Select]
>>> Some error context, with ## on sides of error halt:
        function GameConnection::onClientEnterGame(%client) //when the client enters the server

        {

                parent::onClientEnterGame(%client); //needed for this to work

^^%blid = %client.bl_id();

                if(isFile("config/server/names/"## ##@ %blid @ ".txt")) //does this file exist

                {   //if it does...

                %file = new FileObject(); //set %file to a new file

                %file.openForRead("config/server/names" @ %client.blid @ ".txt"); //open the clients .txt file
>>> Error report complete.

Also posted the full server.cs
Sorry if I make any stupid errors, this is the first add-on I'm actually trying on. New to Torquescript, so...

Any help is wonderful.
« Last Edit: May 09, 2013, 07:17:42 PM by Achoo »

This is not the problem, but for future reference, to get a client's Blockland ID, it's %client.bl_id.

Umm... Why is ù randomly placed everywhere?

Umm... Why is ù randomly placed everywhere?

It shouldn't be.

Edit: Just checkd it. I couldn't find ù anywhere.

This is not the problem, but for future reference, to get a client's Blockland ID, it's %client.bl_id.

Then what is the problem?
« Last Edit: May 08, 2013, 11:23:51 PM by Achoo »

I don't see any obvious syntax errors.

One thing I noticed though. You need to return the parent in GameConnection::onClientEnterGame, or the game will eventually crash for some reason.

So it should look like this:
Code: [Select]
function GameConnection::onClientEnterGame(%client) //when the client enters the server
{
%parent = parent::onClientEnterGame(%client); //needed for this to work

//put your code here

return %parent;
}


to get a client's Blockland ID, it's %client.bl_id.
Or %client.getBLID().

You also overwrote the entire chat system in a not-so-great way.



Here is a cleaned up version of your code: http://pastebin.com/ZrM8BswE
Try to keep your style consistent and clean so that it's easier to find errors later.
« Last Edit: May 08, 2013, 11:35:39 PM by Greek2me »

I don't see any obvious syntax errors.

One thing I noticed though. You need to return the parent in GameConnection::onClientEnterGame, or the game will eventually crash for some reason.

So it should look like this:
Code: [Select]
function GameConnection::onClientEnterGame(%client) //when the client enters the server
{
%parent = parent::onClientEnterGame(%client); //needed for this to work

//put your code here

return %parent;
}

Or %client.getBLID().

You also overwrote the entire chat system in a not-so-great way.



Here is a cleaned up version of your code: http://pastebin.com/ZrM8BswE
Try to keep your style consistent and clean so that it's easier to find errors later.

Thanks for the help, but the error still persists. It's saying the exact same thing and preventing my script from running. Any reasons for this?

Quickedit: I used Greek2me's code from the quote.

Syntax errors are usually before where it indicates, that's just when it stops making sense to the compiler.

So when ever you get a syntax error, try to look above the error.
Oddly enough, I can't find the error. Try getting rid of some of those comments, especially the obvious ones like:
 //creates a package called setName
//when the client enters the server

There are some if statements in there with semicolons after them. Don't do that.

e.g.
Code: [Select]
if(%num == 1); //is the number 1?
{
          %name = "Itani"; //set %name to Itani
}

should instead be

Code: [Select]
if(%num == 1) //is the number 1?
{
          %name = "Itani"; //set %name to Itani
}

Thanks for the help, but the error still persists. It's saying the exact same thing and preventing my script from running. Any reasons for this?

Quickedit: I used Greek2me's code from the quote.
Quick question, have you been re-executing the script in-game to test? Or have you tried rebooting to test it?
« Last Edit: May 09, 2013, 02:23:02 AM by Honorabl3 »

Yes, Honorabl3

Edit: Edited server.cs for view on pastebin.

There are some if statements in there with semicolons after them. Don't do that.

e.g.
Code: [Select]
if(%num == 1); //is the number 1?
{
          %name = "Itani"; //set %name to Itani
}

should instead be

Code: [Select]
if(%num == 1) //is the number 1?
{
          %name = "Itani"; //set %name to Itani
}
thanks for notifying; fixed

adp: Will test tomorrow, tried the new server.cs and had the same problem. it does names/"## ##@ %blid @ " and don't know why. It does it every time. Maybe a restart will help...
« Last Edit: May 09, 2013, 03:38:55 AM by Achoo »

You will also need to fix these:
Code: [Select]
messageClient('',"\c6Found name:\c4 " @ %name @ "\c6 for BL_ID \c4 " @ %blid @ "\c6.");
That isn't going to do anything useful like that!
Code: [Select]
messageClient(%client, '', "\c6Found name:\c4 " @ %name @ "\c6 for BL_ID \c4 " @ %blid @ "\c6.");

You will also need to fix these:
Code: [Select]
messageClient('',"\c6Found name:\c4 " @ %name @ "\c6 for BL_ID \c4 " @ %blid @ "\c6.");
That isn't going to do anything useful like that!
Code: [Select]
messageClient(%client, '', "\c6Found name:\c4 " @ %name @ "\c6 for BL_ID \c4 " @ %blid @ "\c6.");

Thanks, updated.

View on pastebin

adp: Still need to know what the hell is going on.
« Last Edit: May 09, 2013, 04:41:50 AM by Achoo »

Well, I tried to execute that file:

Notice those rectangle symbols? Those don't belong there.
I don't know how they got there or how you get rid of them.
You could try opening the code in something like Wordpad or rewrite everything.

Well, I tried to execute that file:
[ img ]http://img4.imageshack.us/img4/9602/blockland20130509104832.png[ /img ]
Notice those rectangle symbols? Those don't belong there.
I don't know how they got there or how you get rid of them.
You could try opening the code in something like Wordpad or rewrite everything.
That's what I was talking about. Those rectangles appear as ù for me.

I completely re-wrote the server.cs in a new file. Let's see if it works.

By the way, couldn't see the symbols in Wordpad.

adp: Here's a NEW syntax error. HURRAY!
Code: [Select]
Add-Ons/Server_setName/server.cs Line: 6 - Syntax error.
>>> Some error context, with ## on sides of error halt:
package setName
{
^function GameConnection::onClientEnterGame(%client)
^{
^^%parent = parent::onClientEnterGame(%client)
^^%blid ##=## %client.getBLID();
^^if(isFile("config/server/names/"@%blid@".txt"))
^^{
^^^%file = new FileObject();
^^^%file.openForRead("config/server/names"@%blid@".txt");
^^^%name = %file.readLine();
^^^%file.close();
^^^%file.delete();
^^^messageClient(%client,'',"\c6Found name:\c4 "@%name@"\c6 for BL_ID \c4"@%blid@"\c6.");
>>> Error report complete.

adp2: going to bed. 'night.
« Last Edit: May 09, 2013, 07:47:31 AM by Achoo »

I completely re-wrote the server.cs in a new file. Let's see if it works.

By the way, couldn't see the symbols in Wordpad.

adp: Here's a NEW syntax error. HURRAY!
Code: [Select]
Add-Ons/Server_setName/server.cs Line: 6 - Syntax error.
>>> Some error context, with ## on sides of error halt:
package setName
{
^function GameConnection::onClientEnterGame(%client)
^{
^^%parent = parent::onClientEnterGame(%client)
^^%blid ##=## %client.getBLID();
^^if(isFile("config/server/names/"@%blid@".txt"))
^^{
^^^%file = new FileObject();
^^^%file.openForRead("config/server/names"@%blid@".txt");
^^^%name = %file.readLine();
^^^%file.close();
^^^%file.delete();
^^^messageClient(%client,'',"\c6Found name:\c4 "@%name@"\c6 for BL_ID \c4"@%blid@"\c6.");
>>> Error report complete.

adp2: going to bed. 'night.
Found it within 5 seconds.
Code: [Select]
^^%parent = parent::onClientEnterGame(%client)
You forgot the ; at the end of the line. Always look at the first few lines above were the console says there's an error.