Game Development Community

Syntax error and a question...

by Joshua Shoemaker · in Torque 3D Professional · 06/16/2011 (7:02 pm) · 4 replies

I have a Team Death Match game mode script that I'm trying to implement. And when i try to precompile it gives me one syntax error.

First Ill give you the code it is talk is about.

function TeamDeathMatchGame::endGame(%game)
{
   parent::endGame(%game);
   //Tells client that the game is over
   for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
   {
      %cl = ClientGroup.getObject(%clientIndex);
      commandToClient(%cl, 'GameEndTeamGame', %game.teamScore[1], %game.teamScore[2], %game.teamScore[3]);
   }
}

function TeamDeathMatchGame::onGameDurationEnd
{
   parent::onGameDurationEnd();

   for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
   {
      %cl = ClientGroup.getObject(%clientIndex);
      commandToClient(%cl, 'GameEndTeamGame');
   }
}


function TeamDeathMatchGame::onClientEnterGame(%game, %client)


And when it complies is gives this in the output window:



scripts/server/TDM.cs Line: 91 - syntax error
>>> Advanced script error report.  Line 91.
>>> Some error context, with ## on sides of error halt:
   for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
   {
      %cl = ClientGroup.getObject(%clientIndex);
      commandToClient(%cl, 'GameEndTeamGame', %game.teamScore[1], %game.teamScore[2], %game.teamScore[3]);
   }
}

function TeamDeathMatchGame::onGameDurationEnd
{
## ##  parent::onGameDurationEnd();

   for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
   {
      %cl = ClientGroup.getObject(%clientIndex);
      commandToClient(%cl, 'GameEndTeamGame');
   }
}


function TeamDeathMatchGame::onClientEnterGame(%game, %client)
>>> Error report complete.



So I dont really see how Line 91 which is this this line


function TeamDeathMatchGame::onGameDurationEnd
{    //<------ Over there.....
   parent::onGameDurationEnd();




And another quick question. To make a level load a specific game mode, dont you just add this line to the Level Object

gameType = "TeamDeathMatch";

#1
06/16/2011 (7:15 pm)
I think

function TeamDeathMatchGame::onGameDurationEnd
{
...
}

should probably be

function TeamDeathMatchGame::onGameDurationEnd()
{
...
}

#2
06/16/2011 (8:03 pm)
Okay that fixed it, but know its showing another error later on in the script.

>>> Advanced script error report.  Line 139.
>>> Some error context, with ## on sides of error halt:
function TeamDeathMatchGame::onDeath (%game, %client, %sourceObject, %sourceClient, %damageType, %damLoc)
{
   parent::onDeath(%game, %client, %sourceObject, %sourceClient, %damageType, %damLoc);
   %game.incTeamScore(%sourceClient.team.teamId,1);
}

function TeamDeathMatchGame::joinTeam(%game, %client, %teamId,)
##{##
   //No More than three and no less than 0
   if(%teamId > 3 || %teamId < 0)
   return false;
   
   if(%teamid == %client.team.teamId)
   return false;
   
   %game.leaveTeam(%client);
   
   %spawngroups = $Game::DefaultPlayerSpawnGroups;
   
>>> Error report complete.
#3
06/16/2011 (8:25 pm)
Extra comma in the parameter list...
#4
06/17/2011 (11:28 am)
Thanks. Yeah I'm retarded. I always have alot of typos.

But about my other question. To get a gameType to load, dont you just add this line?



gameType = "TeamDeathMatch";


to the Level Object