---
title: "GetPlayerAmmo | open.mp"
description: "Gets the amount of ammo in a player's current weapon."
canonical: https://omp.itsneufox.com/docs/scripting/functions/GetPlayerAmmo
language: en
---

# GetPlayerAmmo

## Description

Gets the amount of ammo in a player's current weapon.

| Name | Description |
| --- | --- |
| playerid | The ID of the player whose ammo to get. |

## Returns

The amount of ammo in the player's current weapon.

## Examples

```c
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/myammo", true))
    {
        new
            ammo = GetPlayerAmmo(playerid),
            string[32];

        format(string, sizeof(string), "Your ammo: %i", ammo);
        SendClientMessage(playerid, -1, string);
        return 1;
    }
    return 0;
}
```

## Notes

warning

The ammo can hold 16-bit values, therefore values over 32767 will return erroneous values.

## Related Functions

-   [SetPlayerAmmo](https://omp.itsneufox.com/docs/scripting/functions/SetPlayerAmmo): Set the ammo of a specific player's weapon.
-   [GetPlayerWeaponData](https://omp.itsneufox.com/docs/scripting/functions/GetPlayerWeaponData): Find out information about weapons a player has.
