Garry's Mod Wiki

Revision Difference

Structures/SWEP#527068

<cat>struct</cat> <structure> <realm>Shared</realm>⤶ <description> Information about a <page text="Scripted Weapons">Scripted_Entities</page>, used by <page>SANDBOX:PlayerGiveSWEP</page> and in SWEP creation. For list of callbacks, see `WEAPON` hooks. 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">(Clientside) Category the SWEP is in</item> <item name="Spawnable" type="boolean" default="false">Whether this SWEP should be displayed in the Q menu</item> <item name="AdminOnly" type="boolean" default="false">Whether or not only admins can spawn the SWEP from their Q menu</item> <item name="PrintName" type="string" default="Scripted Weapon">Nice name of the SWEP</item> <item name="Base" type="string" default="weapon_base">The base weapon to derive from. This **must** be a Lua weapon</item> <item name="m_WeaponDeploySpeed" type="number" default="1">Multiplier of deploy speed</item> <item name="Owner" type="Entity"><deprecated>Use <page>Entity:GetOwner</page>() instead, which is slightly faster.</deprecated>The entity that owns/wields this SWEP, if any.</item> <item name="Author" type="string" default=" ">(Clientside) The author of the SWEP to be shown in weapon selection</item> <item name="Contact" type="string" default=" ">(Clientside) The contacts of the SWEP creator to be shown in weapon selection</item> <item name="Purpose" type="string" default=" ">(Clientside) The purpose of the SWEP creator to be shown in weapon selection</item> <item name="Instructions" type="string" default=" ">(Clientside) How to use your weapon, to be shown in weapon selection</item> <item name="ViewModel" type="string" default="models/weapons/v_pistol.mdl">Path to the view model for your SWEP (what the wielder will see)</item> <item name="ViewModelFlip" type="boolean" default="false">(Clientside) Should we flip the view model? This is needed for some CS:S view models</item> <item name="ViewModelFlip1" type="boolean" default="false">(Clientside) Same as ViewModelFlip, but for the second viewmodel</item> <item name="ViewModelFlip2" type="boolean" default="false">(Clientside) Same as ViewModelFlip, but for the third viewmodel</item> <item name="ViewModelFOV" type="number" default="62">(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)</item> <item name="WorldModel" type="string" default="models/weapons/w_357.mdl">The world model for your SWEP (what you will see in other players hands)</item> <item name="AutoSwitchFrom" type="boolean" default="true">(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</item> <item name="AutoSwitchTo" type="boolean" default="true">(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</item> <item name="Weight" type="number" default="5">(Serverside) 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">(Clientside) The scale of the viewmodel bob (viewmodel movement from left to right when walking around)</item> <item name="SwayScale" type="number" default="1">(Clientside) The scale of the viewmodel sway (viewmodel position lerp when looking around).</item> <item name="BounceWeaponIcon" type="boolean" default="true">(Clientside) Should the weapon icon bounce in weapon selection?</item> <item name="DrawWeaponInfoBox" type="boolean" default="true">(Clientside) Should draw the weapon selection info box, containing SWEP.Instructions, etc.</item> <item name="DrawAmmo" type="boolean" default="true">(Clientside) Should we draw the default HL2 ammo counter?</item> <item name="DrawCrosshair" type="boolean" default="true">(Clientside) Should we draw the default crosshair?</item> <item name="RenderGroup" type="number" default="RENDERGROUP_OPAQUE">(Clientside) 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' )">(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></item> <item name="CSMuzzleFlashes" type="boolean" default="false">(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.</item> <item name="CSMuzzleX" type="boolean" default="false">(Clientside) 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 * <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">(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: <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">(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</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">(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.</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> </fields> </structure>