Skip to content

Commit 6fd4f47

Browse files
committed
feat: add player.FlashbangCount()
This has been asked on discord.
1 parent 020999b commit 6fd4f47

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/demoinfocs/common/player.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,21 @@ func (p *Player) Weapons() []*Equipment {
175175
return res
176176
}
177177

178+
// FlashbangCount returns the amount of flashbangs the player currently has in his inventory.
179+
func (p *Player) FlashbangCount() uint64 {
180+
pawn := p.PlayerPawnEntity()
181+
if pawn == nil {
182+
return 0
183+
}
184+
185+
flashCountProp, ok := pawn.PropertyValue("m_pWeaponServices.m_iAmmo.0014")
186+
if !ok {
187+
return 0
188+
}
189+
190+
return flashCountProp.UInt64()
191+
}
192+
178193
// IsSpottedBy returns true if the player has been spotted by the other player.
179194
// This is NOT "Line of Sight" / FOV - look up "CSGO TraceRay" for that.
180195
// May not behave as expected with multiple spotters.

0 commit comments

Comments
 (0)