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.