> For the complete documentation index, see [llms.txt](https://lua2.fatality.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lua2.fatality.win/api/instances/entities/c_baseentity/c_csweaponbasegun.md).

# C\_CSWeaponBaseGun

This type represents a `CCSWeaponBaseGun` class.

{% hint style="info" %}
This type inherits [`C_BaseEntity` ](/api/instances/entities/c_baseentity.md)type. All of its base methods and fields are also available in this type.
{% endhint %}

## GetMaxSpeed <a href="#get-max-speed" id="get-max-speed"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Returns the maximal player speed when holding this weapon.

**Arguments**

None.

**Returns**

| Type    | Description        |
| ------- | ------------------ |
| `float` | Max speed, in UPS. |

**Example**

```lua
local spd = wep:GetMaxSpeed();
```

***

## GetInaccuracy

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Returns the current inaccuracy value.

**Arguments**

| Name   | Type                                                      | Description  |
| ------ | --------------------------------------------------------- | ------------ |
| `mode` | [`CSWeaponMode`](/api/instances/entities/csweaponmode.md) | Weapon mode. |

**Returns**

| Type    | Description       |
| ------- | ----------------- |
| `float` | Inaccuracy value. |

**Example**

```lua
local inacc = wep:GetInaccuracy(CSWeaponMode.PRIMARY_MODE);
```

***

## GetSpread <a href="#get-spread" id="get-spread"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Returns the current spread value.

**Arguments**

| Name   | Type                                                      | Description  |
| ------ | --------------------------------------------------------- | ------------ |
| `mode` | [`CSWeaponMode`](/api/instances/entities/csweaponmode.md) | Weapon mode. |

**Returns**

| Type    | Description       |
| ------- | ----------------- |
| `float` | Inaccuracy value. |

**Example**

```lua
local spread = wep:GetSpread(CSWeaponMode.PRIMARY_MODE);
```

***

## GetDefIndex <a href="#get-id" id="get-id"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Returns the weapon definition index.

**Arguments**

None.

**Returns**

| Type                                                                      | Description |
| ------------------------------------------------------------------------- | ----------- |
| [`EItemDefinitionIndex`](/api/instances/entities/eitemdefinitionindex.md) | Weapon ID.  |

**Example**

```lua
local wep_id = wep:GetDefIndex();
```

***

## GetType <a href="#get-type" id="get-type"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Returns the weapon type.

**Arguments**

None.

**Returns**

| Type                                                      | Description  |
| --------------------------------------------------------- | ------------ |
| [`CSWeaponType`](/api/instances/entities/csweapontype.md) | Weapon type. |

**Example**

```lua
local type = wep:GetType();
```

***

## GetData <a href="#get-data" id="get-data"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Returns the weapon static data.

**Arguments**

None.

**Returns**

| Type                                                                  | Description  |
| --------------------------------------------------------------------- | ------------ |
| [`CCSWeaponBaseVData`](/api/instances/entities/ccsweaponbasevdata.md) | Weapon data. |

**Example**

```lua
local data = wep:GetData();
```

***

## IsGun <a href="#is-gun" id="is-gun"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Returns `true` if this weapon is a firearm.

**Arguments**

None.

**Returns**

| Type   | Description          |
| ------ | -------------------- |
| `bool` | `true` if a firearm. |

**Example**

```lua
if wep:IsGun() then
    -- ...
end
```

***

## IsAttackable

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Returns `true` if you can attack with this weapon.

**Arguments**

None.

**Returns**

| Type   | Description           |
| ------ | --------------------- |
| `bool` | `true` if can attack. |

**Example**

```lua
if wep:IsAttackable() then
    -- ...
end
```

***

## HasSecondaryAttack

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Returns `true` if this weapon has a secondary attack mode.

**Arguments**

None.

**Returns**

| Type   | Description                              |
| ------ | ---------------------------------------- |
| `bool` | `true` if has the secondary attack mode. |

**Example**

```lua
if wep:HasSecondaryAttack() then
    -- ...
end
```

***

## HasSpread

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Returns `true` if this weapon has spread (e.g. knives do not have any spread).

**Arguments**

None.

**Returns**

| Type   | Description           |
| ------ | --------------------- |
| `bool` | `true` if has spread. |

**Example**

```lua
if wep:HasSpread() then
    -- ...
end
```

[^1]: This field is a method and must be invoked using a colon (:)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://lua2.fatality.win/api/instances/entities/c_baseentity/c_csweaponbasegun.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
