# Player:GetAmmoCount

- **Ortam:** İstemci, Sunucu
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/Player:GetAmmoCount
- **Çeviri tarihi:** 2025-09-08

```lua
number Player:GetAmmoCount( any ammotype )
```

## Açıklama

Oyuncunun sahip olduğu mermi miktarını alır.

## Argümanlar

1. [any](https://gmod.tr/wiki/any) **ammotype**: Mermi türü. [number](https://gmod.tr/wiki/number) (sayı) mermi ID'si veya [string](https://gmod.tr/wiki/string) (metin) mermi adı olabilir.

## Döndürülen Değerler

1. [number](https://gmod.tr/wiki/number): Oyuncunun yedekte sahip olduğu mermi miktarı.

### Örnek

Oyuncunun o anda elinde tuttuğu silahın mermisini döndüren bir fonksiyon.

```lua
function GetAmmoForCurrentWeapon( ply )
	if ( !IsValid( ply ) ) then return -1 end

	local wep = ply:GetActiveWeapon()
	if ( !IsValid( wep ) ) then return -1 end

	return ply:GetAmmoCount( wep:GetPrimaryAmmoType() )
end
```

**Çıktı:** 31

### Örnek

Örnek kullanım. "pistol" mermi türünün ID'si 3'tür.

```lua
print( Entity( 1 ):GetAmmoCount( 3 ) )
print( Entity( 1 ):GetAmmoCount( "3" ) )
print( Entity( 1 ):GetAmmoCount( "pistol" ) )
```

**Çıktı:**

```lua
255
0
255
```

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/Player:GetAmmoCount
