Client/server Cmd functions refuse to work
by Spencer Grey · in Torque Game Engine · 07/05/2006 (9:53 am) · 6 replies
Hey,
I'm going through one of the tutorials now, and I can't get my commandToClient() and clientCmd... stuff to work. It keeps spitting "clientCmdSetScoreCounter: Unknown command." at me in the console.
It refuses to work for my serverCmd calls too. I tried making other functions, so I know that its not a typo in the name of my function ... I'm at a bit of a loss right now. Any help would be appreciated.
If this was asked already, sorry, but I can't find it.
I'm going through one of the tutorials now, and I can't get my commandToClient() and clientCmd... stuff to work. It keeps spitting "clientCmdSetScoreCounter: Unknown command." at me in the console.
function TorqueLogoItem::onCollision(%this, %obj, %col) {
if (%col.getClassName() $= "Player") {
%client = %col.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);
%obj.delete();
%logoCount = logos.getCount();
if (%logoCount > 0)
return;
commandToClient(%client, 'ShowVictory', %client.score);
}
}
function clientCmdSetScoreCounter(%score) {
echo ("score!");
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score) {
MessageBoxYesNo("You Win!",
"Would you like to restart the game?",
"loadMyMission();";
"quit();");
}It refuses to work for my serverCmd calls too. I tried making other functions, so I know that its not a typo in the name of my function ... I'm at a bit of a loss right now. Any help would be appreciated.
If this was asked already, sorry, but I can't find it.
#2
The logoItem.cs collision is working fine. The clientGame.cs is execing properly -- I can call normal functions. I just get that error for calling a cmd function.
07/05/2006 (10:05 am)
Sorry, I should have made that more clear. The onCollision function is in the logoItem.cs file, located in the server directory. The clientCmd stuff is in clientGame.cs, located in the client folder.The logoItem.cs collision is working fine. The clientGame.cs is execing properly -- I can call normal functions. I just get that error for calling a cmd function.
#3
07/05/2006 (10:10 am)
Hmm, well you've already helped. Your comment about having the Cmd functions in the wrong script (client/server) helped me get my serverCmd function working. I'm still not sure why the client wont work, since the onCollision is based in a server side script and the clientCmd's are in a client based script. I'll poke around more ... thanks.
#4
this:
%client = %col.client;
should probably be this:
%client = %obj.client;
You'll probably want to remove that %obj.delete() call as well.
07/05/2006 (10:14 am)
Ah, I see the problem now.this:
%client = %col.client;
should probably be this:
%client = %obj.client;
You'll probably want to remove that %obj.delete() call as well.
#5
There was a damned semi-colon instead of a coma!!! That was screwing the script up. Sigh.
Thanks for the help. Sorry for the stupid bug. Heh.
07/05/2006 (10:35 am)
I'm going to kill myself >.<.MessageBoxYesNo("You Win!",
"Would you like to restart the game?",
"loadMyMission();";
"quit();"
);There was a damned semi-colon instead of a coma!!! That was screwing the script up. Sigh.
Thanks for the help. Sorry for the stupid bug. Heh.
#6
07/05/2006 (10:41 am)
Hey no problem, I even managed to overlook it when I was looking for syntax errors. Its always the stupid little mistakes that cause the most headaches. :)
Associate Scott Burns
GG Alumni