File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -375,6 +375,18 @@ func (p *Player) ClanTag() string {
375375 return getString (p .resourceEntity (), "m_szClan." + p .entityIDStr ())
376376}
377377
378+ // CrosshairCode returns the player's crosshair code or an empty string if there isn't one.
379+ func (p * Player ) CrosshairCode () string {
380+ if p .resourceEntity () == nil {
381+ return ""
382+ }
383+
384+ // if the property doesn't exist we return empty string by default
385+ val , _ := p .resourceEntity ().PropertyValue ("m_szCrosshairCodes." + p .entityIDStr ())
386+
387+ return val .StringVal
388+ }
389+
378390// Ping returns the players latency to the game server.
379391func (p * Player ) Ping () int {
380392 return getInt (p .resourceEntity (), "m_iPing." + p .entityIDStr ())
Original file line number Diff line number Diff line change @@ -377,6 +377,18 @@ func TestPlayer_ClanTag(t *testing.T) {
377377 assert .Equal (t , "SuperClan" , pl .ClanTag ())
378378}
379379
380+ func TestPlayer_CrosshairCode (t * testing.T ) {
381+ pl := playerWithResourceProperty ("m_szCrosshairCodes" , st.PropertyValue {StringVal : "CSGO-jvnbx-S3xFK-iEJXD-Y27Nd-AO6FP" })
382+
383+ assert .Equal (t , "CSGO-jvnbx-S3xFK-iEJXD-Y27Nd-AO6FP" , pl .CrosshairCode ())
384+ }
385+
386+ func TestPlayer_WithoutCrosshairCode (t * testing.T ) {
387+ pl := newPlayer (0 )
388+
389+ assert .Equal (t , pl .CrosshairCode (), "" )
390+ }
391+
380392func TestPlayer_Ping (t * testing.T ) {
381393 pl := playerWithResourceProperty ("m_iPing" , st.PropertyValue {IntVal : 45 })
382394
You can’t perform that action at this time.
0 commit comments