You should be using the && (AND) operator to join conditional statements rather than having a repeated nested if statement without an else.
PHP Code:
//BAD
if (this.safeMoney >= this.takeMoney) {
if (this.takeMoney > 0) {
if (player.account == "PERSONS ACCOUNT HERE") {
//BLAH
}
}
}
//GOOD
if (this.safeMoney >= this.takeMoney && this.takeMoney > 0 && player.account == "BLAH") {
//BLAH
}
//GOOD TOO
if (this.safeMoney >= this.takeMoney &&
this.takeMoney > 0 &&
player.account == "BLAH")
{
//BLAH
}
Quote:
Originally Posted by Gambet
Consecutive if statements without using else if is improper programming.
|
Consecutive
nested if statements are to be avoided without a good reason (can't think of one).