Garry's Mod Wiki



Information about Scripted Weapons (SWEPs), used by SANDBOX:PlayerGiveSWEP 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.


ClassName [string]

Entity class name of the SWEP (file or folder name of your SWEP). This is set automatically

Category [string]

(Clientside) Category the SWEP is in

Default: "Other"

Spawnable [boolean]

Whether this SWEP should be displayed in the Spawn menu

Default: false

AdminOnly [boolean]

Whether or not only admins can spawn the SWEP from their Spawnmenu menu

Default: false

PrintName [string]

Nice name of the SWEP

Default: "Scripted Weapon"

Base [string]

The base weapon to derive from. This must be a Lua weapon

Default: "weapon_base"

m_WeaponDeploySpeed [number]

Multiplier of deploy speed

Default: 1

Owner [Entity]

Use Entity:GetOwner() instead, which is slightly faster.

The entity that owns/wields this SWEP, if any. This is an __index override and not an actual key, so rawget( self:GetTable(), "Owner" ) will return nil.

Weapon [Weapon]

This is equivalent to self in SWEP functions. This only exists for legacy code.

Author [string]

(Clientside) The author of the SWEP to be shown in weapon selection

Default: " "

Contact [string]

(Clientside) The contacts of the SWEP creator to be shown in weapon selection

Default: " "

Purpose [string]

(Clientside) The purpose of the SWEP creator to be shown in weapon selection

Default: " "

Instructions [string]

(Clientside) How to use your weapon, to be shown in weapon selection

Default: " "

ViewModel [string]

Path to the view model for your SWEP (what the wielder will see)

Default: "models/weapons/v_pistol.mdl"

ViewModelFlip [boolean]

(Clientside) Should we flip the view model? This is needed for some CS:S view models

Default: false

ViewModelFlip1 [boolean]

(Clientside) Same as ViewModelFlip, but for the second viewmodel

Default: false

ViewModelFlip2 [boolean]

(Clientside) Same as ViewModelFlip, but for the third viewmodel

Default: false

ViewModelFOV [number]

(Clientside) The 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)

Default: 62

WorldModel [string]

The world model for your SWEP (what you will see in other players hands)

Default: "models/weapons/w_357.mdl"

AutoSwitchFrom [boolean]

(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

Default: true

AutoSwitchTo [boolean]

(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

Default: true

Weight [number]

(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.

Default: 5

BobScale [number]

(Clientside) The scale of the viewmodel bob (viewmodel movement from left to right when walking around)

Default: 1

SwayScale [number]

(Clientside) The scale of the viewmodel sway (viewmodel position lerp when looking around).

Default: 1

BounceWeaponIcon [boolean]

(Clientside) Should the weapon icon bounce in weapon selection?

Default: true

DrawWeaponInfoBox [boolean]

(Clientside) Should draw the weapon selection info box, containing SWEP.Instructions, etc.

Default: true

DrawAmmo [boolean]

(Clientside) Should we draw the default HL2 ammo counter?

Default: true

DrawCrosshair [boolean]

(Clientside) Should we draw the default crosshair?

Default: true

RenderGroup [number]

(Clientside) The SWEP render group, see Enums/RENDERGROUP


Slot [number]

Slot in the weapon selection menu, starts with 0

Default: 0

SlotPos [number]

Position in the slot, should be in the range 0-128

Default: 10

SpeechBubbleLid [number]

(Clientside) Internal variable for drawing the info box in weapon selection

Default: surface.GetTextureID( 'gui/speech_lid' )

WepSelectIcon [number]

(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 surface.GetTextureID. Alternatively you can render custom weapon selection via WEAPON:DrawWeaponSelection.

Default: surface.GetTextureID( 'weapons/swep' )

CSMuzzleFlashes [boolean]

(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.

Default: false

CSMuzzleX [boolean]

(Clientside) Use the X shape muzzle flash instead of the default Counter-Strike muzzle flash. Requires CSMuzzleFlashes to be set to true

Default: false

Primary [table]

Primary attack settings. The table contains these fields:

  • string Ammo - Ammo type ("Pistol", "SMG1" etc)
  • number 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.
  • number DefaultClip - Default ammo in the clip, making it higher than ClipSize will give player additional ammo on spawn
  • boolean Automatic - If true makes the weapon shoot automatically as long as the player has primary attack button held down

Secondary [table]

Secondary attack settings, has same fields as Primary attack settings

UseHands [boolean]

(Clientside) Makes the player models hands bonemerged onto the view model

The gamemode and view models must support this feature for it to work! You can find more information here: Using Viewmodel Hands

Default: false

Folder [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

AccurateCrosshair [boolean]

(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

Default: false

DisableDuplicator [boolean]

Disable the ability for players to duplicate this SWEP

Default: false

ScriptedEntityType [string]

(Clientside) Sets the spawnmenu content icon type for the entity, used by spawnmenu in the Sandbox-derived gamemodes. See spawnmenu.AddContentType for more information.

Default: "weapon"

m_bPlayPickupSound [boolean]

If set to false, the weapon will not play the weapon pick up sound when picked up.

Default: true

IconOverride [string]

(Clientside)If set, overrides the icon path to be displayed in the Spawnmenu for this entity.

Default: "materials/entities/<ClassName>.png"