You could also short the script by doing something like this
PHP Code:
function onKeyPressed(code, key) {
if (key == "b") {
if (this.boots == false) {
this.boots = true;
player.chat = "Boots on!";
}
else if (this.boots == true) {
this.boots = false;
player.chat = "Boots off!";
}
}
}
OR
PHP Code:
function onKeyPressed(code, key) {
if (key == "b") {
this.boots = !this.boots; //change boolean
player.chat = "Boots "@ (this.boots? "on!" : "off!"); //boots are on or off
}
}
Well with the
PHP Code:
this.boots = !this.boots;
is something like gunderak said. It changes the boolean (true to false or false to true). Gunderaks post might also help.
And
PHP Code:
(this.boots ? "on!" : "off!");
is also very nice (in my opinion). Itīs like also checking the boolean. This example might help
PHP Code:
player.chat = this.booleancheck ? "The boolean is true!" : "The boolean is false!";
//or
this.booleancheck ? BooleanTrue() : BooleanFalse();
//if the statement is true, start the function "BooleanTrue()" else if the
//statement is false, start the function "BooleanFalse()"
function BooleanTrue() {
player.chat = "The boolean is true!";
}
function BooleanFalse() {
player.chat = "The boolean is false!";
}
If there are any questions or suggestions about this just ask