Thread: Simple Safe
View Single Post
  #5  
Old 10-13-2008, 03:27 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
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 && player.account == "BLAH") {
  
//BLAH
}
//GOOD TOO
if (this.safeMoney >= this.takeMoney &&
    
this.takeMoney &&
    
player.account == "BLAH")
{
  
//BLAH

Quote:
Originally Posted by Gambet View Post
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).
__________________
Reply With Quote