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.
string ClassNameEntity class name of the SWEP (file or folder name of your SWEP). This is
set automatically
string CategoryThe spawn menu category that this weapon
resides in.
Default: "Other"
boolean SpawnableWhether or not this weapon can be obtained through the
spawn menu.
Default: false
boolean AdminOnlyIf spawnable, this variable determines whether only
administrators can use the button in the spawn menu.
Default: false
string PrintNameThe name of the SWEP displayed in the spawn menu.
Default: "Scripted Weapon"
string BaseThe weapon's base script, relative to
lua/weapons
.
Default: "weapon_base"
Weapon WeaponDeprecated, use SWEP
instead. However, if called in a method; use self
instead.
string ContactThe contact information regarding the SWEP's author.
Default: ""
string ViewModelRelative path to the SWEP's view model.
Default: "models/weapons/v_pistol.mdl"
boolean ViewModelFlipUsed primarily for Counter Strike: Source view models, this variable is used to flip them back to normal.
Default: false
string WorldModelRelative path to the SWEP's world model.
Default: "models/weapons/w_357.mdl"
boolean AutoSwitchFromWhether 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 AutoSwitchToWhether 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 WeightDetermines 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 BobScaleThe scale of the viewmodel bob (viewmodel movement
from left to right when walking around)
Default: 1
number SwayScaleThe scale of the viewmodel sway (viewmodel
position lerp when looking around).
Default: 1
number SlotSlot in the weapon selection menu, starts with
0
Default: 0
number SlotPosPosition in the slot, should be in the range
0-128
Default: 10
number SpeechBubbleLidInternal variable for drawing the info box in weapon selection
Default: surface.GetTextureID( 'gui/speech_lid' )
boolean CSMuzzleFlashesShould 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 CSMuzzleXUse the X shape muzzle flash instead of the
default Counter-Strike muzzle flash. Requires
CSMuzzleFlashes to be set to true.
Default: false
table PrimaryPrimary 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 SecondarySecondary attack settings, has same fields as Primary attack settings
boolean UseHandsMakes 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 HandsDefault: false
string FolderThe 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 AccurateCrosshairMakes 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 IconOverrideIf set,
overrides the icon path to be displayed in the Spawnmenu for this entity.
Default: "materials/entities/<ClassName>.png"