Skip to content

Commit

Permalink
Adding LastPlaceName method for Player, adding new project to README (#…
Browse files Browse the repository at this point in the history
…312)

* added LastPlayerPlace and updated README
* common: m_szLastPlaceName is on player-entity, not resource-entity

Co-authored-by: Markus <mark@saiko.tech>
  • Loading branch information
pnxenopoulos and markus-wa authored Oct 6, 2021
1 parent 253aaff commit 041838a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ There is one caveat however: Beta features - which are marked as such via commen
- [csgoverview](/~https://github.com/Linus4/csgoverview) - A 2D demo replay tool for CS:GO
- [csgo-coach-bug-detector](/~https://github.com/softarn/csgo-coach-bug-detector) - Detects the abuse of an exploit used by some team coaches in professional matches
- [megaclan3000](/~https://github.com/megaclan3000/megaclan3000) - A CS:GO stats page for clans with recent matches and player statistics
- [csgo Python library](/~https://github.com/pnxenopoulos/csgo) - A wrapper for the Golang parser in Python

If your project is using this library feel free to submit a PR or send a message in [Gitter](https://gitter.im/csgodemos/demoinfo-lib) to be included in the list.

Expand Down
5 changes: 5 additions & 0 deletions pkg/demoinfocs/common/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ func (p *Player) MoneySpentThisRound() int {
return getInt(p.resourceEntity(), "m_iCashSpentThisRound."+p.entityIDStr())
}

// LastPlaceName returns the string value of the player's position.
func (p *Player) LastPlaceName() string {
return getString(p.Entity, "m_szLastPlaceName")
}

type demoInfoProvider interface {
IngameTick() int // current in-game tick, used for IsBlinded()
TickRate() float64 // in-game tick rate, used for Player.IsBlinded()
Expand Down
6 changes: 6 additions & 0 deletions pkg/demoinfocs/common/player_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,12 @@ func TestPlayer_SteamID32(t *testing.T) {
assert.Equal(t, uint32(52686539), pl.SteamID32())
}

func TestPlayer_LastPlaceName(t *testing.T) {
pl := playerWithProperty("m_szLastPlaceName", st.PropertyValue{StringVal: "TopofMid"})

assert.Equal(t, "TopofMid", pl.LastPlaceName())
}

func newPlayer(tick int) *Player {
return NewPlayer(mockDemoInfoProvider(128, tick))
}
Expand Down

0 comments on commit 041838a

Please sign in to comment.