DAZZLE'S UPGRADE PACK

If you haven't already done so, upgrade your game by downloading Dazzle's all-in-one upgrade pack. It comes with everything you need for today's servers. Does your blue bar freeze when joining servers? Do you lag in games? Do you get an annoying siren in Phobik's Servers? This is what you need. CLICK HERE TO DOWNLOAD.

Syntaxis Error - Where?

Modding questions, answers, help.....

Moderators: Warfare, Admin, Moderator

Post Reply
User avatar
Cassie
Veteran Member
Veteran Member
Posts: 371
Joined: Fri Dec 29, 2006 4:45 am
Location: Belgium, Ghent
Contact:

Syntaxis Error - Where?

Post by Cassie »

I've been trying to create the script for my new racemod, but both Codeweaver & TT Console say there's a syntax error:

Code: Select all

function StartPU::OnEnter(%db, %this, %tank)
{
	switch( $TimerStarted );
		{
		%client = %tank.client;
		case 1:
		deactivatePackage(Timer);
		messageAll(1,"The Maximum Time Has Exceded" NL "Ride Through The Starter To Restart It!",1);
		break;
		case 0:
		activatePackage(Timer);
		messageAll(1,"The Timer Has Been Started By:" SPC %client.nameBase,1);
		break;
	}
	switch ( %client.passedCheckpoint );
	{
		%client = %tank.client;
		case 1:
		messageAll(1,%client.nameBase SPC "Has Finished The Race In" SPC %timer SPC "Sec.",1);
		messageClient(%client,'serverMessage', "Congrats! You've Finished In" SPC %timer SPC "Sec.",4,4);
		%client.incScore(1,0);
		%client.hurtMe(999);
		break;
		case 0:
		messageAll(1,%client.nameBase SPC "Has Started The Race!",1);
		%client.started = 1;
	}
}

function HalfPU::OnEnter(%this, %db, %tank)
{
	switch(%client.started);
	{
		%client = %tank.client;
		case 1:
		messageClient(%client,'serverMessage',"Go Go Go!" NL "Your At The Half!",4,4);
		%client.started = 0;
		break;
		case 0:
		messageAll(1,%client.nameBase SPC "Tryed To Cheat & Has To Redo The Track!",1);
		%client.hurtMe(999);
		break;
	}
}

$PupTypes = 3;
$Pup[0] = "3";
$Pup[1] = "10";
$Pup[2] = "5";

function TimePU::OnEnter(%this, %db, %tank)
{
	%client = %tank.client;
	messageClient(%client,'serverMessage',"You've Caught A Time-PU",4,4);
	%choice = getRandom($PupTypes-1)
	%timer = %timer - $PupTypes[%choice];
}

$maxTime = 600;

package Timer() 
{
    function timer(%timer) 
    {
		while(%timer <maxTime> %timer)
		return;
		
    }
};

datablock powerupdata(StartPU) 
{ 
category = "PowerUp"; 
 shape = "~/data/shapes/ogmshapes/Checkpoint2/checkpoint.dts"; 
 type = "bounce"; 
shadow = false; 
shadowAnimation = false; 
startOn = true; 
minOff = 1; 
maxOff = 2; 
Sound = ""; 
soundOff = ""; 
};

datablock powerupdata(HalfPU) 
{ 
category = "PowerUp"; 
shape = "~/data/shapes/ogmshapes/Checkpoint2/checkpoint.dts"; 
type = "bounce"; 
shadow = false; 
shadowAnimation = false; 
startOn = true; 
minOff = 1; 
maxOff = 2; 
Sound = ""; 
soundOff = ""; 
};

datablock powerupdata(TimePU) 
{ 
category = "PowerUp"; 
shape = "~/data/shapes/CasRace1/TimePU.dts"; 
type = "bounce"; 
shadow = false; 
shadowAnimation = false; 
startOn = true; 
minOff = 1; 
maxOff = 2; 
Sound = ""; 
soundOff = ""; 
};
Errors

Console Error
game/gametypes/CasRace2.cs Line: 17 - Syntax error.
>>> Advanced script error report. Line 33.
>>> Some error context, with ## on sides of error halt:
function StartPU::OnEnter(%db, %this, %tank)
{
^switch( $TimerStarted );##
##
^^{
^^%client = %tank.client;
^^case 1:
^^deactivatePackage(Timer);
>>> Error report complete.
Codeweaver Error[/i]
Image
User avatar
Warfare
Moderator
Moderator
Posts: 741
Joined: Thu Dec 28, 2006 2:21 pm
Location: Austin, Texas

Post by Warfare »

it looks like you are confusing the switch statements in Java to the ones used in torque

You do not put extra code outside of cases
you do not need to put break;
no semicolons after the switch
good idea to have a default: case

Corrected code:
%client = %tank.client;
switch( $TimerStarted )
{
case 1:
deactivatePackage(Timer);
messageAll(1,"The Maximum Time Has Exceded" NL "Ride Through The Starter To Restart It!",1);
case 0:
activatePackage(Timer);
messageAll(1,"The Timer Has Been Started By:" SPC %client.nameBase,1);
default:
echo("BWHAHAHAHA!");
}
make all of your switches look like this :P
:razz:
User avatar
Cassie
Veteran Member
Veteran Member
Posts: 371
Joined: Fri Dec 29, 2006 4:45 am
Location: Belgium, Ghent
Contact:

Post by Cassie »

Cool, Thx! I just followed the GG-TSL tutorial, which sed i had to use breaks and such.
Post Reply