Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing - Unknown granade model #484

Open
taua-almeida opened this issue Nov 24, 2023 · 1 comment
Open

Missing - Unknown granade model #484

taua-almeida opened this issue Nov 24, 2023 · 1 comment

Comments

@taua-almeida
Copy link

I was just playing around with the lib just for fun. And it seems that a grande model is missing:
unknown grenade model 8528019637059176743

Also for some reason the demo I'm using is not loading the map name too. Am missing something in the code? Don't think demo is corrupted, since I was able to watch normally and tested a whole bunch of others.

Game was played in 11/23/2023. So maybe a new updated change the grenade model.

Code used:

package main

import (
	"encoding/json"
	"fmt"
	"os"

	demoinfocs "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs"
	events "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events"
)

type PlayerStatus struct {
	Name      string
	Kills     int
	Deaths    int
	Assists   int
	Headshots int
	Rank      int
}

func main() {
	if len(os.Args) < 3 {
		fmt.Println("Usage: cs2-demo-reader <demo-file> <player-name>")
	}

	demoFile := os.Args[1]
	playerName := os.Args[2]

	player := parseDemo(demoFile, playerName)

	file, _ := json.MarshalIndent(player, "", " ")

	_ = os.WriteFile("player.json", file, 0644)
}

func parseDemo(demoFilePath string, playerName string) PlayerStatus {
	f, err := os.Open(demoFilePath)
	checkError(err)

	defer f.Close()

	p := demoinfocs.NewParser(f)
	defer p.Close()

	var hs int
	var kills int
	var deaths int
	var assists int
	var rank int

	header, err := p.ParseHeader()
	checkError(err)

	fmt.Printf("Map played: %s\n", header.MapName)

	// Register handler on kill events
	p.RegisterEventHandler(func(e events.Kill) {
		if e.Killer != nil {
			if e.Killer.Name == playerName {
				kills++
				if e.IsHeadshot {
					hs++
				}
			}
		}
		// get deaths
		if e.Victim != nil {
			if e.Victim.Name == playerName {
				deaths++
			}
		}
		// get assists
		if e.Assister != nil {
			if e.Assister.Name == playerName {
				assists++
			}
		}
	})

	p.RegisterEventHandler(func(e events.RankUpdate) {
		if e.Player.Name == playerName {
			rank = e.RankNew
			fmt.Printf("Rank Update: %s (%d) went from rank %d to rank %d, change: %f\n", e.Player.Name, e.SteamID32, e.RankOld, e.RankNew, e.RankChange)
		}
	})

	// Parse to end
	err = p.ParseToEnd()
	checkError(err)

	playerStatus := PlayerStatus{
		Name:      playerName,
		Kills:     kills,
		Deaths:    deaths,
		Assists:   assists,
		Headshots: hs,
		Rank:      rank,
	}
	return playerStatus
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

Prints :

go run main.go .\demo.dem Calitaz
Map played: 
unknown grenade model 8528019637059176743unknown grenade model 8528019637059176743unknown grenade model 8528019637059176743unknown grenade model 8528019637059176743Rank Update: Calitaz (77971698) went from rank 8610 to rank 8968, change: 358.000000

Demo: https://drive.google.com/drive/folders/1S6b_9rwO-G4Tpbh-L5sp2NBcpVxcTyfw?usp=sharing

@taua-almeida
Copy link
Author

Maybe for this one we can add a way to prevent the logging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants