Assign a key to a function
by Gaz Pitchford · in Torque Game Engine · 09/29/2008 (2:32 pm) · 8 replies
I have no idea where to start i purchased the digital shock: soldire pack and have managed to place him in the game and enable the weapon :D ...
My question is how do i asign this:
tsmg1(%player);
to the 'C' key
My question is how do i asign this:
tsmg1(%player);
to the 'C' key
#2
function mountsmg(%val)
{
tsmg1(%player);
}
where do i put the values for the key ?
gaz
09/30/2008 (6:58 am)
I still dont understand i have put this in the default bind file:function mountsmg(%val)
{
tsmg1(%player);
}
where do i put the values for the key ?
gaz
#3
09/30/2008 (7:18 pm)
Something like this?function mountsmg( %val )
{
if ( !%val )
return;
tsmg1($player);
}
moveMap.bind( keyboard, "c", mountsmg );
#4
10/20/2008 (1:00 pm)
I dont understand it... how do i setup the didgital shock: sci-fi soldire to mount his weapon.. ?
#5
1. client/scripts/default.bind.cs - Add the script above but change it to call the server command:
2. server/scripts/commands.cs - And your server command.
10/20/2008 (2:08 pm)
I don't know anything about the digital shock sci-fi soldier but to make a client->server command you do this:1. client/scripts/default.bind.cs - Add the script above but change it to call the server command:
function mountsmg( %val )
{
if ( !%val )
return;
commandToServer('tsmg1($player);
}
moveMap.bind( keyboard, "c", mountsmg );2. server/scripts/commands.cs - And your server command.
function serverCmdtsmg1(%client)
{
// YOUR CODE TO SWITCH WEAPONS HERE
}
#6
Then on your server code, you can get the player object with:
From there you need to add the code that mounts the weapon to the player, which I'm sure can be found in the docs or somewhere on the forum.
10/20/2008 (4:50 pm)
The client code has an incorrect line, it should be:commandToServer('tsmg1');Then on your server code, you can get the player object with:
%player = %client.player
From there you need to add the code that mounts the weapon to the player, which I'm sure can be found in the docs or somewhere on the forum.
#7
function serverCmdYourFunction(%client)
{
}
I've used that before and it seemed to work fine: 216.116.32.49/index.php?sec=mg&mod=resource&page=view&qid=11831
edit: I misread your post... your saying to get the player... so yeh %player = %client.player works... im slow sorry.
10/20/2008 (5:17 pm)
BTW: I could be wrong* but I think that the client is returned automagically when you do a command to server. So the %player = %client.player isn't needed in commands.cs as long as your function looks like:function serverCmdYourFunction(%client)
{
}
I've used that before and it seemed to work fine: 216.116.32.49/index.php?sec=mg&mod=resource&page=view&qid=11831
edit: I misread your post... your saying to get the player... so yeh %player = %client.player works... im slow sorry.
#8
10/22/2008 (2:45 pm)
I cant get it to work :(
Torque 3D Owner Peter Simard