Garry's Mod Wiki

Revision Difference

Structures/SWEP#548624

<cat>struct</cat> <structure> <realm>Shared</realm> <description> Information about <page text="Scripted Weapons">Scripted_Entities</page> (SWEPs), used by <page> SANDBOX:PlayerGiveSWEP</page> and in SWEP creation. For list of callbacks, see <page text="WEAPON Hooks">WEAPON_Hooks</page> While some of the fields may be serverside or clientside only, it is recommended to provide them on both so addons could use their values. </description> <fields> <item name="ClassName" type="string">Entity class name of the SWEP (file or folder name of your SWEP). This is set automatically</item> <item name="Category" type="string" default="Other">The spawn menu category that this weapon resides in.</item> <item name="Spawnable" type="boolean" default="false">Whether or not this weapon can be obtained through the spawn menu. </item> <item name="AdminOnly" type="boolean" default="false">If spawnable, this variable determines whether only administrators can use the button in the spawn menu.</item> <item name="PrintName" type="string" default="Scripted Weapon">The name of the SWEP displayed in the spawn menu.</item> <item name="Base" type="string" default="weapon_base">The weapon's base script, relative to `lua/weapons`.</item> <item name="m_WeaponDeploySpeed" type="number" default="1">The deploy speed multiplier. This does not change the internal deployment speed.</item> <item name="Owner" type="Entity"> <warning>Deprecated, use <page>Entity:GetOwner</page>() instead.</warning> </item> <Item name="Weapon" type="Weapon"> <warning>Deprecated, use `SWEP` instead. However, if called in a method; use `self` instead.</warning> </item> <item name="Author" type="string" default=" ">The SWEP's author.</item> <item name="Contact" type="string" default=" ">The contact information regarding the SWEP's author.</item> <item name="Purpose" type="string" default=" ">The purpose of the SWEP.</item> <item name="Instructions" type="string" default=" ">The instructions regarding the SWEP's usage.</item> <item name="Author" type="string" default="">The SWEP's author.</item> <item name="Contact" type="string" default="">The contact information regarding the SWEP's author.</item> <item name="Purpose" type="string" default="">The purpose of the SWEP.</item> <item name="Instructions" type="string" default="">The instructions regarding the SWEP's usage.</item> <item name="ViewModel" type="string" default="models/weapons/v_pistol.mdl">The client-side, relative path to the SWEP's view model.</item> <item name="ViewModelFlip" type="boolean" default="false">Used primarily for Counter Strike: Source view models, this variable is used to flip them back to normal.</item> <item name="ViewModelFlip1" type="boolean" default="false">Behaves similarly to `ViewModelFlip`, but for the second view model.</item> <item name="ViewModelFlip2" type="boolean" default="false">Behaves similarly to `ViewModelFlip`, but for the third view model.</item> <item name="ViewModelFOV" type="number" default="62">The field of view percieved whilst wielding this `SWEP`.</item> <item name="WorldModel" type="string" default="models/weapons/w_357.mdl">The server-side, relative path to the SWEP's world model.</item> <item name="AutoSwitchFrom" type="boolean" default="true">Whether this weapon can be autoswitched away from when the player runs out of ammo in this weapon or picks up another weapon or ammo</item> <item name="AutoSwitchTo" type="boolean" default="true">Whether this weapon can be autoswitched to when the player runs out of ammo in their current weapon or they pick this weapon up</item> <item name="Weight" type="number" default="5">Determines the priority of the weapon when autoswitching. The weapon being autoswitched from will attempt to switch to a weapon with the same weight that has ammo, but if none exists, it will prioritise higher weight weapons.</item> <item name="BobScale" type="number" default="1">The scale of the viewmodel bob (viewmodel movement from left to right when walking around)</item> <item name="SwayScale" type="number" default="1">The scale of the viewmodel sway (viewmodel position lerp when looking around).</item> <item name="BounceWeaponIcon" type="boolean" default="true">Should the weapon icon bounce in weapon selection?</item> <item name="DrawWeaponInfoBox" type="boolean" default="true">Should draw the weapon selection info box, containing SWEP.Instructions, etc.</item> <item name="DrawAmmo" type="boolean" default="true">Should we draw the default HL2 ammo counter? </item> <item name="DrawCrosshair" type="boolean" default="true">Should we draw the default crosshair? </item> <item name="RenderGroup" type="number" default="RENDERGROUP_OPAQUE">The SWEP render group, see <page>Enums/RENDERGROUP</page> </item> <item name="Slot" type="number" default="0">Slot in the weapon selection menu, starts with `0`</item> <item name="SlotPos" type="number" default="10">Position in the slot, should be in the range `0-128`</item> <item name="SpeechBubbleLid" type="number" default="surface.GetTextureID( 'gui/speech_lid' )">(Clientside) Internal variable for drawing the info box in weapon selection</item> <item name="WepSelectIcon" type="number" default="surface.GetTextureID( 'weapons/swep' )">Path to an texture. Override this in your SWEP to set the icon in the weapon selection. This must be the texture ID, see <page>surface.GetTextureID</page>. Alternatively you can render custom weapon selection via <page> WEAPON:DrawWeaponSelection</page>.</item> <item name="CSMuzzleFlashes" type="boolean" default="false">Should we use Counter-Strike muzzle flashes upon firing? This is required for DoD:S or CS:S view models to fix their muzzle flashes.</item> <item name="CSMuzzleX" type="boolean" default="false">Use the X shape muzzle flash instead of the default Counter-Strike muzzle flash. Requires CSMuzzleFlashes to be set to true</item> <item name="Primary" type="table">Primary attack settings. The table contains these fields: * <page>string</page> Ammo - Ammo type ("Pistol", "SMG1" etc) * <page>number</page> ClipSize - The maximum amount of bullets one clip can hold. Setting it to `-1` means weapon uses no clips, like a grenade or a rocket launch. * <page>number</page> DefaultClip - Default ammo in the clip, making it higher than ClipSize will give player additional ammo on spawn * <page>boolean</page> Automatic - If true makes the weapon shoot automatically as long as the player has primary attack button held down</item> <item name="Secondary" type="table">Secondary attack settings, has same fields as Primary attack settings</item> <item name="UseHands" type="boolean" default="false">Makes the player models hands bonemerged onto the view model <warning>The gamemode and view models **must** support this feature for it to work! You can find more information here: <page text="Using Viewmodel Hands">Using_Viewmodel_Hands</page> </warning> </item> <item name="Folder" type="string">The folder from where the weapon was loaded. This should always be "weapons/weapon_myweapon", regardless whether your SWEP is stored as a file, or multiple files in a folder. It is set automatically on load</item> <item name="AccurateCrosshair" type="boolean" default="false">Makes the default SWEP crosshair be positioned in 3D space where your aim actually is (like on Jeep), instead of simply sitting in the middle of the screen at all times</item> <item name="DisableDuplicator" type="boolean" default="false">Disable the ability for players to duplicate this SWEP</item> <item name="ScriptedEntityType" type="string" default="weapon">Sets the spawnmenu content icon type for the entity, used by spawnmenu in the Sandbox-derived gamemodes. See <page>spawnmenu.AddContentType</page> for more information.</item> <item name="m_bPlayPickupSound" type="boolean" default="true">If set to false, the weapon will not play the weapon pick up sound when picked up.</item> <item name="IconOverride" type="string" default="materials/entities/<ClassName>.png">(Clientside)If set, overrides the icon path to be displayed in the Spawnmenu for this entity.</item> </fields> </structure>