View Single Post
  #3  
Old 09-10-2011, 09:59 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Make a system npc to manage the equipping and un-equipping. I.e:

-System/Equipment

PHP Code:
//#CLIENTSIDE
public function equip(wep) {
  if (
isEquipped(wep)) {
    
unequip();
  } else {
    
this.equipped wep;
  }
}

public function 
unequip() {
  
this.equipped "";
}

public function 
isEquipped(wep) {
  return (
this.equipped == wep);

then in your weapon you can do:

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  
// Equip/Unequip Weapon
  
("-System/Equipment").equip(this);
  
// Check if Weapons is Equipped
  
if (("-System/Equipment").isEquipped(this)) {
    
// set appropriate anis
  
} else {
    
// return anis to normal
  
}
}

function 
onKeyPressed() {
  if ((
"-System/Equipment").isEquipped(this)) {
    if (
keydown(5)) fireWeapon();
  }
}

function 
fireWeapon() {
  
// pew pew pew
  // RED DRAGONS

This is just a basic implementation, you can expand upon it and do more in -System/Equipment to the point where all you're doing is setting different configuration variables in your weapons.

Also use keydown(5) instead of key == "s" that way players can re-assign the attack key via F3 Options.
__________________
Quote:
Reply With Quote