Author Topic: Function with keybind  (Read 1112 times)

I'm wanting to execute a function when i press a key binded button and then execute another when pressed again, like a toggle. How would i go about doing this?

This needs to be in a client.cs file.

$remapDivision[$remapCount] = "Section Name";
$remapName[$remapCount] = "Action Name";
$remapCmd[$remapCount] = "function";
$remapCount++;

then in the remapCmd part, where nexus said function, that's to call a function (ie, "quack", would call function quack(){})
then in the function for a toggle you could then have
$togglethingy = !$togglethingy;
if($togglethingy)
{
a();
}
else
{
b();
}
a and b as functions

function myToggle(%val) {
    if(!%val)
        return;
    $myToggle = !$myToggle;
}

Thanks guys, i'm going to test it now.

function myToggle(%val) {
    if(!%val)
        return;
    $myToggle = !$myToggle;
}
isn't that basicaly the same as what i said, for the toggling?

isn't that basicaly the same as what i said, for the toggling?

nop.


because his toggles when the person presses a button.  Yours is determined by whether the button is held down or not.

What if the keybind setting thingies were put in a server.cs?

Would it break?

What if the keybind setting thingies were put in a server.cs?

Would it break?
No, it wouldn't, it will just do nothing.

because his toggles when the person presses a button.  Yours is determined by whether the button is held down or not.
disregarding the imput method i ment, just the toggling, as he never asked for the input method, just a keybind and a toggle

disregarding the imput method i ment, just the toggling, as he never asked for the input method, just a keybind and a toggle
when i press a key binded button and then execute another when pressed again