Author Topic: Script crashes game - produces no errors - RESOLVED on Pg. 2  (Read 1877 times)

Something is wrong with this code I wrote and i don't know what.  Could a more trained eye take a look at it and see if I did something stupid?

Link  Old.

Updated version with console here.

« Last Edit: April 05, 2014, 05:45:51 AM by SWAT One »

And it crashes when you do what?

Probably not related to you crashing but here are some things you are doing wrong/could do better.


Don't make a function that only calls one function. It's pointless.


When you compare a string, the end comparison should be in quotes if it's not a variable. Example below.
Code: (Wrong Way) [Select]
if(%var $= poodle face)
{
     echo("True.");
}
Code: (Right Way.) [Select]
if(%var $= "poodle face")
{
     echo("True.");
}
Code: (Also Right Way) [Select]
%this = "poodle face";

if(%var $= %this)
{
     echo("True.");
}

Media fire is acting stupid for me, do you mind putting your code here?

Media fire is acting stupid for me, do you mind putting your code here?
I think it breaks the character limit.

And it crashes when you do what?
Good point.  It crashes when I just finish "Loading Music".  There's that pause, and then when it says "Connection Accepted", it immediately crashes.  I think I saw something in console that happened when the server crashed, saying it had just activated the script's package.


Title says it all.  Produces no errors.  Activating package fimodguide.  And it ends there.

It's curious because there's that one scfipt in there initiating on game connection.

try changing the line from

Code: [Select]
function gameconnection::OnClientEnterGame(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i,%k)
{
messageClient(%this,'','\c6For the \c4Floating Islands Guide\c6, say \c3/fi help\c6.');
Parent::OnClientEnterGame(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i,%k);
}

to

Code: [Select]
function gameconnection::OnClientEnterGame(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i,%k)
{
messageClient(%this,'','\c6For the \c4Floating Islands Guide\c6, say \c3/fi help\c6.');
return Parent::OnClientEnterGame(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i,%k);
}

I think it breaks the character limit.

The character limit is 20000
« Last Edit: April 04, 2014, 02:13:17 PM by Nexus »

  • You're packaging an inordinate number of functions that you're defining, when you only need to package GameConnection::onClientEnterGame.
  • You're defining a huge number of functions for no reason other than to send a single line to the client.
  • %category is misspelled, and a switch$ would be more readable than an if/elif/else tree anyway.

However none of those things should be causing a fatal crash. Post your console.log please.

The character limit is 20000
I think he mean't the variable limit for a function.

I think he mean't the variable limit for a function.
No, it was said as a response to why he didn't post it straight into OP.

I haven't downloaded the script, but I saw from Nexus' code quote an error.

Code: [Select]
function gameconnection::OnClientEnterGame(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i,%k)
{
messageClient(%this,'','\c6For the \c4Floating Islands Guide\c6, say \c3/fi help\c6.');
Parent::OnClientEnterGame(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i,%k);
}

You can not use ' for strings, you must use " . The 's in the second argument is an exception, something to do with the engine. I'm not sure if this is causing the crash, however it definitely isn't helping.

It should be
Code: [Select]
function gameconnection::OnClientEnterGame(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i,%k)
{
messageClient(%this,'',"\c6For the \c4Floating Islands Guide\c6, say \c3/fi help\c6.");
return Parent::OnClientEnterGame(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i,%k);
}

What? If anything, he should be using ' there, considering the string will never change.

Here's the server startup with trace not enabled.

Changes since last check-in:

  • Added return to return Parent::OnClientEnterGame
  • Removed extra text from package, leaving just the function involving gameconnection::OnClientEnterGame in the package.
  • Changed ' to " to test.  Produced no differing results.
« Last Edit: April 05, 2014, 03:48:48 AM by SWAT One »

Code: [Select]
package fimodguide
{
function gameconnection::OnClientEnterGame(%cl)
{
messageClient(%cl, '', "\c6For the \c4Floating Islands Guide\c6, say \c3/fi help\c6.");
return Parent::OnClientEnterGame(%cl);
}
};
activatepackage(fimodguide);

function servercmdfi(%client, %category, %sub0, %sub1)
{
if(%category $= define)
{
//Define category
if(%sub0 $= Travelers)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c3Travelers\c6 are those who are undeclared in intention.  They can be harmful or docile.  You can become a \c3Traveler\c6 by saying \c3/do join Travelers\c6.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub0 $= Pirates)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c3Pirates\c6 are those who have declared hostile intentions against players.  You can become a \c3Pirate\c6 by saying \c3/do join Pirates\c6.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub0 $= SM)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c3SM\c6 stands for Server Maintenance.  This is a position reserved for Admins, usually Super Admins.  Non-competitive.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub0 $= Teams)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c3Teams\c6 are special groups within your \c3Category\c6.  You can damage people in your \c3Category\c6, but not people in your \c3Team\c6.  For more information on \c3Teams\c6, say \c3/team help\c6.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub0 $= Categories)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c3Categories\c6 are types of people based on alignment.  This includes \c3Travelers\c6 and \c3Pirates\c6.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub0 $= Blocs)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c3Blocs\c6 are the floating islands that you see around you.  For more information on the \c3Blocs\c6, say \c3/fi backstory\c6.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub0 $= Radio)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c3Radio\c6 is a way of communicating with your comerades from all across the archipelago.  For more information, say \c3/radio help\c6.");
%client.play2d(Beep_Checkout_Sound);
}
else
{
messageclient(%client,'',"\c0ERROR: \c6It appears you typed something wrong.  Make sure the format follows \c3/fi define [name]\c6.  For more info, say \c3/fi index\c6 for a list of official names.");
%client.play2d(Beep_TryAgain_Sound);
}
}
else if(%category $= story)
{
//Story category
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c6Type \c3/fi define blocs\c6 for information on the blocs.");
messageClient(%client,'',"\c6Type \c3/fi define categories\c6 for information on the categories of alignment.");
messageClient(%client,'',"\c6Type \c3/fi define teams\c6 for information on teams.");
messageClient(%client,'',"\c6Type \c3/fi define radio\c6 for information on the radio communications system.");
messageClient(%client,'',"\c6Type \c3/fi define travelers\c6 for information on the traveler category.");
messageClient(%client,'',"\c6Type \c3/fi define pirates\c6 for information on the pirate category.");
messageClient(%client,'',"\c4Scroll up if you can't see all of this text.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%category $= index)
{
//Index category
if(%sub0 $= families)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c6Type \c3/fi index definitions\c6 for a list of definable terms.");
messageClient(%client,'',"\c6Type \c3/fi index commands\c6 for a list of commands at use in this mod.");
messageClient(%client,'',"\c6Type \c3/fi index server\c6 for a list mods used and required including download links, recommended settings, and credits.");
messageClient(%client,'',"\c6Type \c3/fi index families\c6 to display this list.");
messageClient(%client,'',"\c4Scroll up if you can't see all of this text.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub0 $= definitions)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c6Type \c3/fi define blocs\c6 for information on the blocs.");
messageClient(%client,'',"\c6Type \c3/fi define categories\c6 for information on the categories of alignment.");
messageClient(%client,'',"\c6Type \c3/fi define teams\c6 for information on teams.");
messageClient(%client,'',"\c6Type \c3/fi define radio\c6 for information on the radio communications system.");
messageClient(%client,'',"\c6Type \c3/fi define travelers\c6 for information on the traveler category.");
messageClient(%client,'',"\c6Type \c3/fi define pirates\c6 for information on the pirate category.");
messageClient(%client,'',"\c4Scroll up if you can't see all of this text.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub0 $= commands)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c6Type \c3/do travelers join\c6 to join the travelers.");
messageClient(%client,'',"\c6Type \c3/do pirates join\c6 to join the pirates.");
messageClient(%client,'',"\c6Type \c3/do rlink enable\c6 when near a remote synch panel to synch with it.");
messageClient(%client,'',"\c6Type \c3/do rlink disable\c6 when near a remote synch panel to de-synch with it.");
messageClient(%client,'',"\c6Type \c3/radio help\c6 for instructions on how to use the radio mod.");
messageClient(%client,'',"\c6Type \c3/team help\c6 for instructions on how to manage teams.");
messageClient(%client,'',"\c4Scroll up if you can't see all of this text.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub0 $= server)
{
if(%sub1 $= mods)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c5You do not have to download these Add-Ons, but if you download these and place them in your Add-Ons folder, your load will be much faster.");
messageClient(%client,'',"\c7This list is still under construction.");
messageClient(%client,'',"\c4Scroll up if you can't see all of this text.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub1 $= settings)
{
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c6If you wish to load quicker and play with lower quality, it is recommended that you disable downloading \c4textures\c6, \c4sounds\c6, and \c4music\c6.");
messageClient(%client,'',"\c6If you wish to play with higher quality, but possibly load slower, it is recommended that you enable downloading \c4textures\c6, \c4sounds\c6, and \c4music\c6.");
messageClient(%client,'',"\c4Scroll up if you can't see all of this text.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub1 $= credits)
{
for(%i=0;%i<20;%i++)
{
%dLine = %dLine @ "= ";
%sLine = %sLine @ "- ";
}
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client, '', %dLine);
messageClient(%client,'',"\c3Project Leader");
messageClient(%client,'',"\c1[\c2BL_ID 14257\c1]  \c6Tuevon");
messageClient(%client, '', %sLine);
messageClient(%client,'',"\c3Builders");
messageClient(%client,'',"\c1[\c2BL_ID 14257\c1]  \c6Tuevon");
messageClient(%client,'',"\c1[\c2BL_ID 5200\c1]  \c6sos339");
messageClient(%client, '', %sLine);
messageClient(%client,'',"\c3Eventers");
messageClient(%client,'',"\c1[\c2BL_ID 14257\c1]  \c6Tuevon");
messageClient(%client, '', %sLine);
messageClient(%client,'',"\c3Scripters");
messageClient(%client,'',"\c1[\c2BL_ID 14257\c1]  \c6Tuevon");
messageClient(%client, '', %dLine);
messageClient(%client,'',"\c6If you would like to contribute, ask Tuevon for assistance.");
%client.play2d(Beep_Checkout_Sound);
}
else if(%sub1 $= list)
{
messageClient(%client,'',"\c6Type \c3/fi index server mods\c6 for information on mods used, required and recommended for better gameplay.");
messageClient(%client,'',"\c6Type \c3/fi index server settings\c6 for aid on recommended settings for quick play, detail play, or anything imbetween.");
messageClient(%client,'',"\c6Type \c3/fi index server credits\c6 for credits on those who made this server possible.");
messageClient(%client,'',"\c6Type \c3/fi index server list\c6 to display this list.");
}
else
{
messageclient(%client,'',"\c0ERROR: \c6Say \c3/fi index server list\c6 for a list of catagories.");
%client.play2d(Beep_TryAgain_Sound);
}
}
else
{
messageclient(%client,'',"\c0ERROR: \c6Say \c3/resource index families\c6 for a list of catagories.");
%client.play2d(Beep_TryAgain_Sound);
}
}
else if(%category $= help)
{
//Help category
messageClient(%client,'',"\c6 ===== \c4Floating Islands Guide\c6 =====");
messageClient(%client,'',"\c6Type \c3/fi define [name]\c6 for a description on any bit of content.");
messageClient(%client,'',"\c6Type \c3/fi story\c6 for a backstory.");
messageClient(%client,'',"\c6Type \c3/fi index\c6 for a list of all sorts of goodies.");
messageClient(%client,'',"\c6Type \c3/fi help\c6 to display this list.");
messageClient(%client,'',"\c4Scroll up if you can't see all of this text.");
%client.play2d(Beep_Checkout_Sound);
}
else
{
messageclient(%client,'',"\c0ERROR: \c6Say \c3/fi help\c6 for assistance.");
%client.play2d(Beep_TryAgain_Sound);
}
}


Replaced all the function functions with their inline equivalent; removed the superfluous variables from onClientEnterGame (shouldn't cause problems, but, well, Torque); replaced the three kilobytes of comment banners with 80 bytes of comment lines. Try it now.
« Last Edit: April 05, 2014, 04:10:38 AM by Xalos »