Skip to content

Commit 8640f84

Browse files
committed
feat: add player.FlashbanCount()
1 parent dc2f24a commit 8640f84

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pkg/demoinfocs/common/player.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,25 @@ func (p *Player) Weapons() []*Equipment {
196196
return res
197197
}
198198

199+
// FlashbangCount returns the amount of flashbangs the player currently has in his inventory.
200+
func (p *Player) FlashbangCount() int {
201+
if p.demoInfoProvider.IsSource2() {
202+
pawn := p.PlayerPawnEntity()
203+
if pawn == nil {
204+
return 0
205+
}
206+
207+
flashCountProp, ok := pawn.PropertyValue("m_pWeaponServices.m_iAmmo.0014")
208+
if !ok {
209+
return 0
210+
}
211+
212+
return int(flashCountProp.S2UInt64())
213+
}
214+
215+
return p.Entity.PropertyValueMust("m_iAmmo.015").Int()
216+
}
217+
199218
// IsSpottedBy returns true if the player has been spotted by the other player.
200219
// This is NOT "Line of Sight" / FOV - look up "CSGO TraceRay" for that.
201220
// May not behave as expected with multiple spotters.

0 commit comments

Comments
 (0)