Game Development Community

Gameone Tutorial Scoring functions not getting called

by Dan Rubenfield · in Torque Game Engine · 07/13/2006 (12:32 pm) · 3 replies

So the clientGame.cs functions don't seem to be getting called.

First, the code:

Logoitem.cs:

function TorqueLogoItem::onCollision(%this, %obj, %col)
{
if(%col.getClassName()$= "Player")
{

$client = %col.client;
%client.score++;
commandToClient(%client, "SetScoreCounter", 2);
commandToClient(%client, "TestEcho");
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount>0)
{
return;
}
else
{
commandToClient(%client, 'ShowVictory', %client.score);
}
}
}


I added in a testEcho command as well as the original value to see if that was the problem.


ClientGame.cs (in gameOne/Client)

function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}


function clientCmdTestEcho()
{
echo("THIS IS A TEST");
}
function clientCmdShowVictory()
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game?",
"loadMyMission();",
"quit();");
}


Using the debugger and breakpoints I can tell that the collision code is executing, it's going to the client command lines on the server but it never gets to the client (or the breakpoints).

Simgroups are named right, Objects are the right objects, I tried deleting the dso's and recompiling.

Any ideas?

#1
07/15/2006 (9:03 pm)
I'm having the same problem. I just posted without realizing you had a post already. I've spent the past 2 hours trying to figure it out..... I'm new to the TGE but have over 10 years of "programming" experience and I have no clue as to where the problem is coming from....
#2
07/16/2006 (12:00 pm)
I can answer Dan's problem, at least.

Where it reads:

$client = %col.client;

Change this to read:

%client = %col.client;

The $ indicates a global variable, and % indicates a local variable. $client is not the same as %client, and for the rest of the code block after the line I corrected, you are referencing it as %client, so you have no reference.
#3
07/18/2006 (6:26 am)
I had a similar problem, and it was resolved here, maybe it'll help.