# Spawnar Armas

O EQPG-Pro oferece dois métodos para spawnar armas de forma segura pelo **server-side**. É fundamental utilizar esses exports ao invés das natives padrão para evitar detecções do anticheat.

{% hint style="danger" %}
**Não use** `GiveWeaponToPed` diretamente pelo client-side! Isso será detectado como cheat. Sempre utilize os exports do EQPG-Pro pelo server-side.
{% endhint %}

{% hint style="warning" %}
**⚠️ Aviso Importante — `addAmmo` descontinuado** Se você está usando `exports["resource-eqpg"]:addAmmo`, **troque para a native original do FiveM** `SetPedAmmo`. O export `addAmmo` pode causar bugs com munição. Veja a [seção de migração](#migrar-addammo-para-setpedammo) abaixo.
{% endhint %}

## Método 1 — `giveWeapons` (Recomendado)

Ideal para dar **uma ou mais armas** de uma vez com configurações detalhadas.

```lua
exports["eqpg-pro"]:giveWeapons(source, {
    [modelHash] = {
        ammo = ammoCount,
        isHidden = false,
        bForceInHand = false
    }
})
```

### Parâmetros da Arma

| Parâmetro      | Tipo      | Descrição                                         |
| -------------- | --------- | ------------------------------------------------- |
| `modelHash`    | `hash`    | Model ou hash da arma (ex: `"WEAPON_PISTOL"`)     |
| `ammo`         | `integer` | Quantidade de munição (`0` para sem munição)      |
| `isHidden`     | `boolean` | `true` para esconder da roda de armas             |
| `bForceInHand` | `boolean` | `true` para equipar diretamente na mão do jogador |

### Exemplos

**Dar uma arma:**

```lua
exports["eqpg-pro"]:giveWeapons(source, {
    ["WEAPON_PISTOL"] = {
        ammo = 100,
        isHidden = false,
        bForceInHand = true
    }
})
```

**Dar várias armas:**

```lua
exports["eqpg-pro"]:giveWeapons(source, {
    ["WEAPON_PISTOL"] = { ammo = 100, isHidden = false, bForceInHand = false },
    ["WEAPON_SMG"]    = { ammo = 200, isHidden = false, bForceInHand = false },
    ["WEAPON_RIFLE"]  = { ammo = 150, isHidden = false, bForceInHand = false }
})
```

***

## Método 2 — `EQPGWeapon`

Substituto direto da native `GiveWeaponToPed`. Use se você está migrando código existente que já usa essa native.

```lua
exports["eqpg-pro"]:EQPGWeapon(GetPlayerPed(source), modelHash, ammoCount, isHidden, bForceInHand)
```

### Parâmetros

| Parâmetro              | Tipo          | Descrição                  |
| ---------------------- | ------------- | -------------------------- |
| `GetPlayerPed(source)` | `integer`     | Ped do jogador             |
| `modelHash`            | `string/hash` | Model ou hash da arma      |
| `ammoCount`            | `integer`     | Quantidade de munição      |
| `isHidden`             | `boolean`     | Esconder da roda de armas  |
| `bForceInHand`         | `boolean`     | Equipar diretamente na mão |

### Exemplo

```lua
-- Antes (native padrão — NÃO USE!)
-- GiveWeaponToPed(GetPlayerPed(source), "WEAPON_PISTOL", 100, false, true)

-- Depois (com EQPG-Pro ✅)
exports["eqpg-pro"]:EQPGWeapon(GetPlayerPed(source), "WEAPON_PISTOL", 100, false, true)
```

***

## Remover Armas

```lua
-- Remove todas as armas temporariamente
exports["eqpg-pro"]:removeWeapons(source)

-- Remove armas do personagem permanentemente
exports["eqpg-pro"]:removeCharacterWeapons(source)
```

***

## Migrar `addAmmo` para `SetPedAmmo`

{% hint style="danger" %}
O export `exports["resource-eqpg"]:addAmmo` está **descontinuado** e causa bugs com munição. Substitua pela native original do FiveM `SetPedAmmo`.
{% endhint %}

**Antes (problemático):**

```lua
exports["resource-eqpg"]:addAmmo(source, weaponHash, ammoCount)
```

**Depois (correto ✅):**

```lua
-- Aplica a munição diretamente via native do FiveM
SetPedAmmo(GetPlayerPed(source), weaponHash, ammoCount)
```

**Exemplo completo:**

```lua
local ped = GetPlayerPed(source)
local weaponHash = GetHashKey("WEAPON_PISTOL")

-- Dar a arma primeiro (via EQPG-Pro)
exports["eqpg-pro"]:giveWeapons(source, {
    ["WEAPON_PISTOL"] = { ammo = 0, isHidden = false, bForceInHand = false }
})

-- Depois definir a munição com a native
SetPedAmmo(ped, weaponHash, 100)
```

{% hint style="info" %}
`SetPedAmmo` é uma native nativa do FiveM/GTA, não requer nenhum export. Funciona diretamente no server-side.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eqpg-network.gitbook.io/eqpg-docs/guias-de-integracao/spawnar-armas.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
