Garry's Mod Wiki

Garry's Mod Wiki

Description

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.

Members

string ClassName
Entity class name of the SWEP (file or folder name of your SWEP). This is set automatically
string ClassNameOverride
If set, overrides the classname of the SWEP.
string Category
The spawn menu category that this weapon resides in.

Default: "Other"

boolean Spawnable
Whether or not this weapon can be obtained through the spawn menu.

Default: false

boolean AdminOnly
If spawnable, this variable determines whether only administrators can use the button in the spawn menu.

Default: false

string PrintName
The name of the SWEP displayed in the spawn menu.

Default: "Scripted Weapon"

string Base
The weapon's base script, relative to lua/weapons.

Default: "weapon_base"

number m_WeaponDeploySpeed
The deploy speed multiplier. This does not change the internal deployment speed.

Default: 1

Entity Owner
Deprecated, use Entity:GetOwner() instead.
Weapon Weapon
Deprecated, use SWEP instead. However, if called in a method; use self instead.
string Author
The SWEP's author.

Default: ""

string Contact
The contact information regarding the SWEP's author.

Default: ""

string Purpose
The purpose of the SWEP.

Default: ""

string Instructions
The instructions regarding the SWEP's usage.

Default: ""

string ViewModel
Relative path to the SWEP's view model.

Default: "models/weapons/v_pistol.mdl"

boolean ViewModelFlip
Used primarily for Counter Strike: Source view models, this variable is used to flip them back to normal.

Default: false

boolean ViewModelFlip1
Behaves similarly to ViewModelFlip, but for the second view model.

Default: false

boolean ViewModelFlip2
Behaves similarly to ViewModelFlip, but for the third view model.

Default: false

number ViewModelFOV
The field of view percieved whilst wielding this SWEP.

Default: 62

string WorldModel
Relative path to the SWEP's world model.

Default: "models/weapons/w_357.mdl"

boolean AutoSwitchFrom
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

boolean AutoSwitchTo
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

number Weight
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

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

Default: 1

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

Default: 1

boolean BounceWeaponIcon
Should the weapon icon bounce in weapon selection?

Default: true

boolean DrawWeaponInfoBox
Should draw the weapon selection info box, containing SWEP.Instructions, etc.

Default: true

boolean DrawAmmo
Should we draw the default HL2 ammo counter?

Default: true

boolean DrawCrosshair
Should we draw the default crosshair?

Default: true

number RenderGroup
The SWEP render group, see RENDERGROUP enum. If unset, the engine will decide the render group based on the SWEPs world model.
number Slot
Slot in the weapon selection menu, starts with 0

Default: 0

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

Default: 10

number SpeechBubbleLid
Internal variable for drawing the info box in weapon selection

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

number WepSelectIcon
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' )

boolean CSMuzzleFlashes
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

boolean CSMuzzleX
Use the X shape muzzle flash instead of the default Counter-Strike muzzle flash. Requires CSMuzzleFlashes to be set to true.

Default: false

table Primary
Primary attack settings. The table contains these fields:
  • string Ammo - Ammo type (Pistol, SMG1, etc.) See game.AddAmmoType.
  • 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
table Secondary
Secondary attack settings, has same fields as Primary attack settings
boolean UseHands
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

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
boolean AccurateCrosshair
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

boolean DisableDuplicator
Disable the ability for players to duplicate this SWEP

Default: false

string ScriptedEntityType
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"

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

Default: true

string IconOverride
If set, overrides the icon path to be displayed in the Spawnmenu for this entity.

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

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...