Created
May 17, 2020 11:23
-
-
Save markus-wa/559b11f66b94b8ada35814f673dc153c to your computer and use it in GitHub Desktop.
CS:GO Demos: getting crosshair codes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs" | |
events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events" | |
) | |
func main() { | |
f, err := os.Open("test.dem") | |
if err != nil { | |
panic(err) | |
} | |
defer f.Close() | |
p := dem.NewParser(f) | |
p.RegisterEventHandler(func(start events.MatchStart) { | |
fmt.Println("------------------------------------") | |
fmt.Println("------------------------------------") | |
for _, pl := range p.GameState().Participants().Playing() { | |
for i := 0; i < 64; i++ { | |
v, b := pl.ResourceEntity().PropertyValue(fmt.Sprintf("m_szCrosshairCodes.%03d", i)) | |
if b == true && v.StringVal != "" { | |
fmt.Println(pl, v.StringVal) | |
} | |
} | |
} | |
fmt.Println("------------------------------------") | |
fmt.Println("------------------------------------") | |
}) | |
// Parse to end | |
err = p.ParseToEnd() | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment