# getPedWeapon (Server)

> Gets the weapon a ped or player is holding.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Peds
- **URL**: https://wiki.mymp.gg/en/getPedWeapon-server
- **Counterpart**: Also exists on the client, with its own implementation: [getPedWeapon (Client)](https://wiki.mymp.gg/en/getPedWeapon-client.md)

## Syntax

```lua
int|false getPedWeapon(ped ped)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `ped` | `ped` | The ped or player. |

## Returns

The weapon type in the current slot (`0` when the slot is empty), or `false` if the element is not a ped or a player.

The type is the weapon's `type` in the pack's weapon metadata, such as `22` for `PISTOL`.

## Example

```lua
addCommandHandler("weapon", function(player)
    outputDebugString(getPlayerName(player) .. " holds weapon " .. getPedWeapon(player))
end)
```

### Coming from MTA

Takes no slot: it always returns the weapon in the current slot.

## See also

- [getPedWeapon (Client)](https://wiki.mymp.gg/en/getPedWeapon-client.md): Gets the weapon a ped or player is holding, as this client knows it.
- [giveWeapon (Server)](https://wiki.mymp.gg/en/giveWeapon.md): Gives a weapon with ammo to a ped or player.
- [getPedArmour (Server)](https://wiki.mymp.gg/en/getPedArmour.md): Gets the armour of a ped or player.
