SWEP
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
boolean AdminOnly
If spawnable, this variable determines whether only
administrators can use the button in the spawn menu.
Default: false
number m_WeaponDeploySpeed
The deploy speed multiplier. This does not change the
internal deployment speed.
Default: 1
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
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 DrawWeaponInfoBox
Should draw the weapon selection info
box, containing SWEP.Instructions, etc.
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 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
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
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. The path is relative to the
materials/
folder.Default: "entities/<ClassName>.png"