@@ -368,6 +368,51 @@ func (p *Player) Armor() int {
368368 return getInt (p .Entity , "m_ArmorValue" )
369369}
370370
371+ // RankType returns the current rank type that the player is playing for.
372+ // CS:GO values:
373+ // -1 -> Information not present, the demo is too old
374+ // 0 -> None/not available
375+ // 6 -> Classic Competitive
376+ // 7 -> Wingman 2v2
377+ // 10 -> Danger zone
378+ //
379+ // CS2 values:
380+ // -1 -> Not available, demo probably not coming from a Valve server
381+ // 0 -> None?
382+ // 11 -> Classic Competitive
383+ func (p * Player ) RankType () int {
384+ if p .demoInfoProvider .IsSource2 () {
385+ return getInt (p .Entity , "m_iCompetitiveRankType" )
386+ }
387+
388+ // This prop is not available in old demos
389+ if prop , exists := p .resourceEntity ().PropertyValue ("m_iCompetitiveRankType." + p .entityIDStr ()); exists {
390+ return prop .Int ()
391+ }
392+
393+ return - 1
394+ }
395+
396+ // Rank returns the current rank of the player for the current RankType.
397+ // CS:GO demos -> from 0 to 18 (0 = unranked/unknown, 18 = Global Elite)
398+ // CS2 demos -> Number representation of the player's rank.
399+ func (p * Player ) Rank () int {
400+ if p .demoInfoProvider .IsSource2 () {
401+ return getInt (p .Entity , "m_iCompetitiveRanking" )
402+ }
403+
404+ return getInt (p .resourceEntity (), "m_iCompetitiveRanking." + p .entityIDStr ())
405+ }
406+
407+ // CompetitiveWins returns the amount of competitive wins the player has for the current RankType.
408+ func (p * Player ) CompetitiveWins () int {
409+ if p .demoInfoProvider .IsSource2 () {
410+ return getInt (p .Entity , "m_iCompetitiveWins" )
411+ }
412+
413+ return getInt (p .resourceEntity (), "m_iCompetitiveWins." + p .entityIDStr ())
414+ }
415+
371416// Money returns the amount of money in the player's bank.
372417func (p * Player ) Money () int {
373418 if p .demoInfoProvider .IsSource2 () {
0 commit comments