In addition to what Crow said, you'd also ideally want to replace
PHP Code:
findweapon(name).onWeaponFired();
with
PHP Code:
findweapon(name).trigger("WeaponFired", "param1", "param2", "etc.");
since it'll avoid causing scripterrors in weapons where the onWeaponFired() function isn't defined.