Author Topic: How do I add keybinds to commands?  (Read 985 times)

/title
I'm very new to torquescript, so please explain it slowly. All help is appreciated, thanks!

Code: [Select]
$remapDivision[$remapCount] = "Division";
$remapName[$remapCount] = "Name";
$remapCmd[$remapCount] = "Function Called";
$remapCount++;

He wont be able to understand jes

He wont be able to understand jes
Umm, I don't know how to spoon feed people.

An example:
Code: [Select]
$remapDivision[$remapCount] = "Abusive Admin Commands";
$remapName[$remapCount] = "Kill";
$remapCmd[$remapCount] = "Function ServercmdKill";
$remapCount++;
Is this valid?

Umm, I don't know how to spoon feed people.
I'm pretty sure even if you did he wouldn't understand

An example:
Code: [Select]
$remapDivision[$remapCount] = "Abusive Admin Commands";
$remapName[$remapCount] = "Kill";
$remapCmd[$remapCount] = "Function ServercmdKill";
$remapCount++;
Is this valid?
I am interested, and I want to know if this is valid or not :/

I am interested, and I want to know if this is valid or not :/
You were very close. Instead of saying "function serverCmdKill, you need to create a function that then calls serverCmdKill.

So like this:
Code: [Select]
$remapDivision[$remapCount] = "Abusive Admin Commands";
$remapName[$remapCount] = "Kill";
$remapCmd[$remapCount] = "killStuff"; // This has to be the name of a client-sided function
$remapCount++;

function killStuff(%state)
{
// %state tells us whether they are pressing or releasing the mouse button.
// If it is true, that means they are pressing it.
// If it is false, that means they are releasing it.

// We only want our command to be called when they press it, so we do this:
if(%state)
{
// This is where we tell the server what we want to do
// Send the command 'kill'. This is how you would call serverCmdKill from the client.
commandToServer('kill');
}
}



Code: [Select]
$remapDivision[$remapCount] = "Abusive noob commands";
$remapName[$remapCount] = "Kill";
$remapCmd[$remapCount] = "CommandToServer('kill')";
$remapCount++;
Woo


But what would be the use of a /kill?
You need a /kill (name) and that cannot be done with keybind

that's the function that we were assuming the be already created...

Code: [Select]
function servercmdkill(%cl,%t)
{
     findclientbyname(%t).player.kill();
}

Well, tell me this. How is your keyboard supposed to know what player to kill if you just press a button? If you wanted to make a keybind to type /kill so you could provide a name, while useless, would look like this:

Code: [Select]
$remapDivision[$remapCount] = "Abusive Noob Commands";
$remapName[$remapCount] = "Kill";
$remapCmd[$remapCount++ - 1] = "openKill";

function openKill(%tog)
{
if(!%tog || !isObject(serverConnection)) //Checks if you're releasing the key or not connected to a server. If either are true:
return; //Don't continue.
newMessageHud.open("SAY");
NMH_Type.setValue("/kill ");
}
« Last Edit: July 22, 2012, 10:19:54 AM by Slicks555 »

$remapCmd[$remapCount++ - 1] = "openKill";
What exactly are you trying to do there?

What exactly are you trying to do there?
increment the global variable than use the value one less than it, it's just compressing two lines into one, where as in Jess' example it was
$remapCmd[$remapCount] = "xxx";
$remapCount++;

Well I figured that, it just looked wrong. Guess I should have tested it