SWEP Structure

From Garry's Mod
Revision as of 04:33, 14 April 2016 by Code gs (Talk | contribs)
Jump to: navigation, search
Information about a SWEP, used by SANDBOX:PlayerGiveSWEP and SWEP creation. For list of callbacks, see Category: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.

Type Name Description
string ClassName

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

string Category

(Clientside) Category the SWEP is in

Default: "Other"

boolean Spawnable

Whether this SWEP should be displayed in the Q menu

Default: false

boolean AdminOnly

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

Default: false

string PrintName

(Clientside) Nice name of the SWEP

Default: "Scripted Weapon"

string Base

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

Default: "weapon_base"

number m_WeaponDeploySpeed

Multiplier of deploy speed

Default: nil

Entity Owner

The entity that owns/wields this SWEP, if any

string Author

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

Default: ""

string Contact

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

Default: ""

string Purpose

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

Default: ""

string Instructions

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

Default: ""

string ViewModel

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

Default: "models/weapons/v_pistol.mdl"

boolean ViewModelFlip

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

Default: false

boolean ViewModelFlip1

Same as ViewModelFlip, but for the second viewmodel

Default: false

boolean ViewModelFlip2

Same as ViewModelFlip, but for the third viewmodel

Default: false

number ViewModelFOV

An angle of FOV used for the view model ( Recommended value is 54 )

Default: 62

string WorldModel

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

Default: "models/weapons/w_357.mdl"

boolean AutoSwitchFrom

(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

boolean AutoSwitchTo

(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

number Weight

(Serverside) Decides whether we should switch from/to this

Default: 5

number BobScale

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

Default: 1

number SwayScale

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

Default: 1

boolean BounceWeaponIcon

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

Default: true

boolean DrawWeaponInfoBox

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

Default: true

boolean DrawAmmo

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

Default: true

boolean DrawCrosshair

(Clientside) Should we draw the default crosshair?

Default: true

number RenderGroup

(Clientside) The SWEP render group, see RENDERGROUP_ Enums

Default: RENDERGROUP_OPAQUE

number Slot

(Clientside) Slot in the weapon selection menu, starts with 0

Default: 0

number SlotPos

(Clientside) Position in the slot, should be in the range 0-128

Default: 10

number SpeechBubbleLid

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

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

number WepSelectIcon

(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

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

boolean CSMuzzleFlashes

(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

boolean CSMuzzleX

(Clientside) 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)
  • number ClipSize - The maximum amount of bullets one clip can hold
  • 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

Warning: The gamemode and view models must support this feature for it to work!

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

(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

Personal tools
Navigation