Author Topic: Keybind that makes you chat something  (Read 1060 times)

This does what I'm trying to do, except 20x better:
https://dl.dropboxusercontent.com/u/20459676/Client_ServerCommandGui.zip (by Nexus)

This kind of thing has already been pretty much mastered lol

Original post:
I'm trying to make a keybind that, when pressed, makes you say "/deposit 99999" in chat. I don't really have much of a clue what I'm doing but here's the code so far:
Code: [Select]
$remapDivision[$remapCount] = "AutoType";
$remapName[$remapCount] = "Deposit 99999";
$remapCmd[$remapCount] = "clientCmdChatMessage";
$remapCount++;[/s]
 function clientCmdChatMessage( %cl, %voice, %pitch, %line, %pre, %name, %suf, %msg )
    {
        parent::clientCmdChatMessage( %cl, %voice, %pitch, "/deposit 99999", %pre, %name, %suf, %msg );
    }
It doesn't even show the option to set the keybind in controls
« Last Edit: September 26, 2014, 10:50:40 PM by Farad »

1. clientCmds are commands that the server can tell the client to call, to tell them to do something. There isn't a ton of use for calling them manually
2. clientCmdChatMessage is the command for your client recieving a message
3. The command to send a chat message to the server is commandtoserver('messagesent','Your text here'); However...
4. slash commands are interpreted by the client, and turned into a commandtoserver call. "/deposit 99999" becomes commandtoserver('deposit','99999');

You'd want to do something like this

Code: [Select]
$remapDivision[$remapCount] = "AutoType";
$remapName[$remapCount] = "Deposit 99999";
$remapCmd[$remapCount] = "quickDeposit";
$remapCount++;


function quickDeposit()
{
       commandtoserver('deposit',99999);
}

https://dl.dropboxusercontent.com/u/20459676/Client_ServerCommandGui.zip (by Nexus)

This kind of thing has already been pretty much mastered lol

1. clientCmds are commands that the server can tell the client to call
2. clientCmdChatMessage is the command for your client recieving a message
3. The command to send a chat message to the server is commandtoserver('messagesent','Your text here'); However...
4. slash commands are interpreted by the client, and turned into a commandtoserver call. "/deposit 99999" becomes commandtoserver('deposit','99999');

You'd want to do something like this

Code: [Select]
$remapDivision[$remapCount] = "AutoType";
$remapName[$remapCount] = "Deposit 99999";
$remapCmd[$remapCount] = "quickDeposit";
$remapCount++;


function quickDeposit()
{
       commandtoserver('deposit',99999);
}
You're forgetting the boolean. This will call /deposit 99999 twice. Once when you push the key, once when you release it.

Because it's called by a key bind, the function will be called with a boolean variable(a variable that's either positive or negative) which will indicate if the key was pushed(positive) or released(negative).

Now we're making sure that the you're only calling /deposit 99999 when the key is pushed, and not released. You can change it to if(!%bool) if you want it to be called when the key is released instead.
Code: [Select]
$remapDivision[$remapCount] = "AutoType";
$remapName[$remapCount] = "Deposit 99999";
$remapCmd[$remapCount] = "quickDeposit";
$remapCount++;

function quickDeposit(%bool)
{
       if(%bool)
       {
              commandtoserver('deposit',99999);
       }
}


https://dl.dropboxusercontent.com/u/20459676/Client_ServerCommandGui.zip (by Nexus)

This kind of thing has already been pretty much mastered lol
no need for me to script this now. thanks, locking