Game Development Community

moveMap.bindCmd(keyboard, "e", "commandToServer(\'Warp1\');", "");

by JJ62(#0005) · in Torque Game Engine · 02/15/2009 (4:54 am) · 4 replies

Hi there,
I am trying to implement a simple tutorial I seen in Advanced 3d game programming all in one. I have wrote some script to warp a player but Im having some problems binding it to a key. Its in chapter 3 of this book so maybe someone has done the same thing and can help?
First of all I created a file warp.cs in the server folder containing this code

function serverCmdWarp1(%client)
{
echo("We are warpin!!!!");
%avatar=%client.player;
%eyeVector=%avatar.getEyeVector();
%warpVector=%vectorScale(%eyeVector,50);
%currentPos=%avatar.getPosition();
%newPos=vectorAdd(%currentPos,%warpVector);
%currentTrans=%avatar.getTransform();
%orientation=getWords(%currentTrans,3);
%newTransform=%newPos SPC %orientation;
%avatar.setTransform(%newTransform);
}

Then in game.cs I wrote

exec("./blockRotation.cs");

At this point I went to the client folder and located the keybinding script.

Here I entered

moveMap.bindCmd(keyboard, "e", "commandToServer(\'Warp1\');", "");

The problem is something to do with this I think.
The console gives me the message
serverCmdWarp1: Unknown command

I not sure what to do. Any help would be appreciated!!!!!

#1
02/15/2009 (5:36 am)
change moveMap to commandtoServer(\'serverCmdWarp1');","");
#2
02/15/2009 (6:01 am)
In your server scripts, make sure that the the Warp1 function is indeed serverCmdWarp1 and that the script file that its in is getting executed correctly without any errors. If there are errors in the script file then it won't be executed properly, which means your function technically won't exist.

ex:
//server side
function serverCmdWarp1(%client)
{
  //do my code
}

//client side
moveMap.bindCmd(keyboard, "e", "commandToServer('Warp1');", "");

Also, %vectorScale(%eyeVector,50); should be: vectorScale(%eyeVector,50); - this could be the real problem. %vectorScale() is not a proper function call, or a proper variable, so when the script is executed the engine will pickup on that and error out. Check your console.
#3
02/15/2009 (6:44 am)
Thanks guys for help it seems to be working now!!!!!!!!!!
#4
02/15/2009 (7:03 am)
Good luck with it. Cheers.