Revision Difference
Structures/SWEP#516889
<cat>struct</cat>
{{Structure⤶
|Description=Information about a SWEP, used by <page>SANDBOX:PlayerGiveSWEP</page> and SWEP creation. For list of callbacks, see .⤶
<structure>⤶
<description>⤶
Information about a SWEP, used by <page>SANDBOX:PlayerGiveSWEP</page> and SWEP creation. For list of callbacks, see .⤶
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.
|Fields={{StructureField|string|ClassName|Entity class name of the SWEP (file or folder name of your SWEP). This is set automatically}}{{StructureField|string|Category|(Clientside) Category the SWEP is in|"Other"}}{{StructureField|boolean|Spawnable|Whether this SWEP should be displayed in the Q menu|false}}{{StructureField|boolean|AdminOnly|Whether or not only admins can spawn the SWEP from their Q menu|false}}{{StructureField|string|PrintName|Nice name of the SWEP|"Scripted Weapon"}}{{StructureField|string|Base|The base weapon to derive from. This **must** be a Lua weapon|"weapon_base"}}{{StructureField|number|m_WeaponDeploySpeed|Multiplier of deploy speed|1}}{{StructureField|Entity|Owner|The entity that owns/wields this SWEP, if any}}{{StructureField|string|Author|(Clientside) The author of the SWEP to be shown in weapon selection|""}}{{StructureField|string|Contact|(Clientside) The contacts of the SWEP creator to be shown in weapon selection|""}}{{StructureField|string|Purpose|(Clientside) The purpose of the SWEP creator to be shown in weapon selection|""}}{{StructureField|string|Instructions|(Clientside) How to use your weapon, to be shown in weapon selection|""}}{{StructureField|string|ViewModel|Path to the view model for your SWEP (what the wielder will see)|"models/weapons/v_pistol.mdl"}}{{StructureField|boolean|ViewModelFlip|(Clientside) Should we flip the view model? This is needed for some CS:S view models|false}}{{StructureField|boolean|ViewModelFlip1|(Clientside) Same as ViewModelFlip, but for the second viewmodel|false}}{{StructureField|boolean|ViewModelFlip2|(Clientside) Same as ViewModelFlip, but for the third viewmodel|false}}{{StructureField|number|ViewModelFOV|(Clientside) An angle of FOV used for the view model (Half-Life value is 90; Half-Life 2 is 54; Counter-Strike: Source is 74; Day of Defeat: Source is 45)|62}}{{StructureField|string|WorldModel|The world model for your SWEP (what you will see in other players hands)|"models/weapons/w_357.mdl"}}{{StructureField|boolean|AutoSwitchFrom|(Serverside) 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|true}}{{StructureField|boolean|AutoSwitchTo|(Serverside) Whether this weapon can be autoswitched to when the player runs out of ammo in their current weapon or they pick this weapon up|true}}{{StructureField|number|Weight|(Serverside) Decides whether we should switch from/to this|5}}{{StructureField|number|BobScale|(Clientside) The scale of the viewmodel bob (viewmodel movement from left to right when walking around)|1}}{{StructureField|number|SwayScale|(Clientside) The scale of the viewmodel sway (viewmodel position lerp when looking around).|1}}{{StructureField|boolean|BounceWeaponIcon|(Clientside) Should the weapon icon bounce in weapon selection?|true}}{{StructureField|boolean|DrawWeaponInfoBox|(Clientside) Should draw the weapon selection info box, containing SWEP.Instructions, etc.|true}}{{StructureField|boolean|DrawAmmo|(Clientside) Should we draw the default HL2 ammo counter?|true}}{{StructureField|boolean|DrawCrosshair|(Clientside) Should we draw the default crosshair?|true}}{{StructureField|number|RenderGroup|(Clientside) The SWEP render group, see <page>RENDERGROUP</page>|RENDERGROUP_OPAQUE}}{{StructureField|number|Slot|Slot in the weapon selection menu, starts with 0|0}}{{StructureField|number|SlotPos|Position in the slot, should be in the range 0-128|10⤶
</description>⤶
<fields>{{StructureField|string|ClassName|Entity class name of the SWEP (file or folder name of your SWEP). This is set automatically</fields>⤶
⤶
</structure>⤶
⤶
{{StructureField|string|Category|(Clientside) Category the SWEP is in|"Other"}}{{StructureField|boolean|Spawnable|Whether this SWEP should be displayed in the Q menu|false}}{{StructureField|boolean|AdminOnly|Whether or not only admins can spawn the SWEP from their Q menu|false}}{{StructureField|string|PrintName|Nice name of the SWEP|"Scripted Weapon"}}{{StructureField|string|Base|The base weapon to derive from. This **must** be a Lua weapon|"weapon_base"}}{{StructureField|number|m_WeaponDeploySpeed|Multiplier of deploy speed|1}}{{StructureField|Entity|Owner|The entity that owns/wields this SWEP, if any}}{{StructureField|string|Author|(Clientside) The author of the SWEP to be shown in weapon selection|""}}{{StructureField|string|Contact|(Clientside) The contacts of the SWEP creator to be shown in weapon selection|""}}{{StructureField|string|Purpose|(Clientside) The purpose of the SWEP creator to be shown in weapon selection|""}}{{StructureField|string|Instructions|(Clientside) How to use your weapon, to be shown in weapon selection|""}}{{StructureField|string|ViewModel|Path to the view model for your SWEP (what the wielder will see)|"models/weapons/v_pistol.mdl"}}{{StructureField|boolean|ViewModelFlip|(Clientside) Should we flip the view model? This is needed for some CS:S view models|false}}{{StructureField|boolean|ViewModelFlip1|(Clientside) Same as ViewModelFlip, but for the second viewmodel|false}}{{StructureField|boolean|ViewModelFlip2|(Clientside) Same as ViewModelFlip, but for the third viewmodel|false}}{{StructureField|number|ViewModelFOV|(Clientside) An angle of FOV used for the view model (Half-Life value is 90; Half-Life 2 is 54; Counter-Strike: Source is 74; Day of Defeat: Source is 45)|62}}{{StructureField|string|WorldModel|The world model for your SWEP (what you will see in other players hands)|"models/weapons/w_357.mdl"}}{{StructureField|boolean|AutoSwitchFrom|(Serverside) 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|true}}{{StructureField|boolean|AutoSwitchTo|(Serverside) Whether this weapon can be autoswitched to when the player runs out of ammo in their current weapon or they pick this weapon up|true}}{{StructureField|number|Weight|(Serverside) Decides whether we should switch from/to this|5}}{{StructureField|number|BobScale|(Clientside) The scale of the viewmodel bob (viewmodel movement from left to right when walking around)|1}}{{StructureField|number|SwayScale|(Clientside) The scale of the viewmodel sway (viewmodel position lerp when looking around).|1}}{{StructureField|boolean|BounceWeaponIcon|(Clientside) Should the weapon icon bounce in weapon selection?|true}}{{StructureField|boolean|DrawWeaponInfoBox|(Clientside) Should draw the weapon selection info box, containing SWEP.Instructions, etc.|true}}{{StructureField|boolean|DrawAmmo|(Clientside) Should we draw the default HL2 ammo counter?|true}}{{StructureField|boolean|DrawCrosshair|(Clientside) Should we draw the default crosshair?|true}}{{StructureField|number|RenderGroup|(Clientside) The SWEP render group, see <page>RENDERGROUP</page>|RENDERGROUP_OPAQUE}}{{StructureField|number|Slot|Slot in the weapon selection menu, starts with 0|0}}{{StructureField|number|SlotPos|Position in the slot, should be in the range 0-128|10⤶
}}{{StructureField|number|SpeechBubbleLid|(Clientside) Internal variable for drawing the info box in weapon selection|surface.GetTextureID( "gui/speech_lid" )}}{{StructureField|number|WepSelectIcon|(Clientside) 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>|surface.GetTextureID( "weapons/swep" )}}{{StructureField|boolean|CSMuzzleFlashes|(Clientside) 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.|false}}{{StructureField|boolean|CSMuzzleX|(Clientside) Use the X shape muzzle flash instead of the default Counter-Strike muzzle flash. Requires CSMuzzleFlashes to be set to true|false}}{{StructureField|table|Primary|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
* <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
}}{{StructureField|table|Secondary|Secondary attack settings, has same fields as Primary attack settings}}{{StructureField|boolean|UseHands|(Clientside) 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: [Using Viewmodel Hands](/gmod/Using_Viewmodel_Hands)</warning>|false
}}{{StructureField|string|Folder|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}}{{StructureField|boolean|AccurateCrosshair|(Clientside) 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|false}}{{StructureField|boolean|DisableDuplicator|Disable the ability for players to duplicate this SWEP|false}}{{StructureField|string|ScriptedEntityType|(Clientside) 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.|"weapon"
}}{{StructureField|boolean|m_bPlayPickupSound|If set to false, the weapon will not play the weapon pick up sound when picked up.|true}}
}}