Game Development Community

CommandToClient... clientCmd...

by Vilain Design · in Torque Game Engine · 07/12/2006 (9:08 am) · 4 replies

Hi all
i have a problem when i want to call a function on the client side, when i call it, it adds a cliendCmd in front of my function...

in playGui.cs file

function PlayGui::increaseLapCounter(%this)
{
// Increase the lap.
PlayGui.lap++;
PlayGui.updateLapCounter();
}

in checkpoint.cs file:

... lots of code
commandToClient(%obj.client, 'increaseLapCounter');
... more code

in console i can see the error
clientCmdincreaseLapCounter: Unknown command.

can anyone help me ?

#1
07/12/2006 (9:35 am)
Well your error message is referring to this function that usually resides inside of playGui.cs

function clientCmdSetMaxLaps(%laps)
{
	// Reset the current lap to 1 and set the max laps.
	PlayGui.lap = 1;
	PlayGui.maxLaps = %laps;
	PlayGui.updateLapCounter();
}

This is being called inside of game.cs

function GameConnection::onClientEnterGame(%this)
{
   commandToClient(%this, 'SyncClock', $Sim::Time - $Game::StartTime);
   commandToClient(%this, 'SetMaxLaps', $Game::Laps);

So that's the error you want to fix. Most likely a simple typo.
#2
07/12/2006 (9:41 am)
Vilain, all client commands are supposed to start with clientCmd. just rename all your client functions to begin with "clientCmd" instead.
#3
07/12/2006 (9:45 am)
Even when they were starting with clientCmd, it didnt work.

and i have functions that dont begin with clientCmd that works...

when i renamed it, i had the error: clientCmdclientCmdincreaseLapCounter: Unknown command.

kinda strange isnt it ?
#4
07/12/2006 (10:34 am)
Don't rename it in your call to commandToClient, instead you need to rename the function on the client side.

So, you have somewhere a function that reads something like this:

in playGui.cs file

function PlayGui::increaseLapCounter(%this)
{
// Increase the lap.
PlayGui.lap++;
PlayGui.updateLapCounter();
}

Change that instead to be:

function PlayGui::clientCmdIncreaseLapCounter(%this)
{
// Increase the lap.
PlayGui.lap++;
PlayGui.updateLapCounter();
}

Your commandToClient should call 'IncreaseLapCounter', not 'clientCmdIncreaseLapCounter'. The clientCmd part (and serverCmd for commands sent back to the server) is added in automatically by the software itself.