/*note In torquescript they used a classname call to the weapon class to perform * the onPickUp and onUse. Unfortunately, we don't have that ability in CSharp. */ public override bool onUse(ShapeBase obj) { if (obj.getMountedImage(Constants.WeaponSlot) == this["image"].AsInt()) return false; Audio.AudioServerPlay3D("WeaponUseSound", obj.getTransform()); obj.mountImage(this["image"], Constants.WeaponSlot, true, string.Empty); if (obj["client"].AsBool()) { if (this["description"] != string.Empty) message.MessageClient(obj["client"], "MsgWeaponUsed", "\\c3%1 \\c5 selected.", this["description"]); else message.MessageClient(obj["client"], "MsgWeaponUsed", console.addTaggedString(@"\c0Weapon selected")); } if (obj.isInNamespaceHierarchy("Player")) return false; Player player = obj._ID; player.allowAllPoses(); SimObject image = this["image"]; if (image["jumpingDisallowed"].AsBool()) player.allowJumping(false); if (image["jetJumpingDisallowed"].AsBool()) player.allowJetJumping(false); if (image["sprintDisallowed"].AsBool()) player.allowSprinting(false); if (image["crouchDisallowed"].AsBool()) player.allowCrouching(false); if (image["proneDisallowed"].AsBool()) player.allowProne(false); if (image["swimmingDisallowed"].AsBool()) player.allowSwimming(false); return true; }
public override bool onUse(ShapeBase obj) { if (obj.getMountedImage(Constants.WeaponSlot) == this["image"].AsInt()) { return(false); } Audio.AudioServerPlay3D("WeaponUseSound", obj.getTransform()); obj.mountImage(this["image"], Constants.WeaponSlot, true, string.Empty); if (obj["client"].AsBool()) { if (this["description"] != string.Empty) { message.MessageClient(obj["client"], "MsgWeaponUsed", "\\c3%1 \\c5 selected.", this["description"]); } else { message.MessageClient(obj["client"], "MsgWeaponUsed", console.addTaggedString(@"\c0Weapon selected")); } } if (obj.isInNamespaceHierarchy("Player")) { return(false); } Player player = obj._ID; player.allowAllPoses(); SimObject image = this["image"]; if (image["jumpingDisallowed"].AsBool()) { player.allowJumping(false); } if (image["jetJumpingDisallowed"].AsBool()) { player.allowJetJumping(false); } if (image["sprintDisallowed"].AsBool()) { player.allowSprinting(false); } if (image["crouchDisallowed"].AsBool()) { player.allowCrouching(false); } if (image["proneDisallowed"].AsBool()) { player.allowProne(false); } if (image["swimmingDisallowed"].AsBool()) { player.allowSwimming(false); } return(true); }