Author Topic: Toggling Error  (Read 4583 times)

So I have this script that is supposed to toggle on and off.
Whenever I press the keybind for it, it only toggles on.
How do I fix this?

Code: [Select]
$remapDivision[$remapCount] = "Bot";
$remapName[$remapCount] = "Timescale";
$remapCmd[$remapCount] = "ToggleTimescale";
$remapCount++;
$Timescale = true;

function ToggleTimescale() {
if ($Timescale = false)
{
clientcmdtimescale(1);
$Timescale = true;
}
else if ($Timescale = true)
{
clientcmdtimescale(0.2);
$Timescale = false;
}

}

Change the if($a = b) to if($a == b)

Change the if($a = b) to if($a == b)
i'm so dumb
edit: I have another question: How would you enable it once and it stays on until you press the keybind again?
« Last Edit: December 12, 2014, 06:34:02 PM by Czar »

Keybound functions have one argument, the function is called once with this argument set to true on key press, and again on key release with the argument set to false
Right now it's turning off when you release the key because you're not checking for that

Quote
function keybindFunc(%var)
{
    if(%var)
    {
        //Do stuff
    }

}

Keybound functions have one argument, the function is called once with this argument set to true on key press, and again on key release with the argument set to false
Right now it's turning off when you release the key because you're not checking for that

thanks