Assign a key to a function
by Gaz Pitchford · in Torque Game Engine · 09/29/2008 (7:32 am) · 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/29/2008 (11:58 pm)
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 (12:18 pm)
Something like this?function mountsmg( %val )
{
if ( !%val )
return;
tsmg1($player);
}
moveMap.bind( keyboard, "c", mountsmg );
#4
10/20/2008 (6:00 am)
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 (7:08 am)
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 (9:50 am)
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 (10:17 am)
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 (7:45 am)
I cant get it to work :(
Torque 3D Owner Peter Simard
Default Studio Name