View Single Post
  #2  
Old 09-10-2011, 09:49 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
PHP Code:
function onWeaponFired() {
  if (! 
this.isEquipped()) {
    return 
this.equip(); // it's not already equipped, so equip it
  
}
  
  
// it's already equipped
  
this.fire();
}

function 
GraalControl.onKeyCode(temp.codetemp.key) {
  if (
temp.key == "s" && this.isEquipped()) {
    
// pressed "s" while equipped, unequip it
    
this.unequip();
  }

Just do something like this.


Also, note that this is incorrect:

PHP Code:
player.weapons[selectedweapon] == this.name 
weapons is an array of weapon objects, not weapon names. The only reason it works is because the weapon object is coerced into a string, which is then compared to the current weapon's name.

The correct way would be to do
PHP Code:
player.weapons[selectedweapon] == this 
However, the best way would just be to do

PHP Code:
player.weapon == this 
(player.weapon always refers to the currently selected weapon)
__________________
Reply With Quote