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

How to get crc-map code? #483

Open
NintyS opened this issue Nov 23, 2023 · 8 comments
Open

How to get crc-map code? #483

NintyS opened this issue Nov 23, 2023 · 8 comments

Comments

@NintyS
Copy link

NintyS commented Nov 23, 2023

How to get CRC code of map in CS2 version of the library?
The msgs2.CSVCMsg_ServerInfo don't have a GetMapCrc() function as I see

@dankotov
Copy link

dankotov commented Dec 9, 2023

@NintyS were you ever able to figure out?

@NintyS
Copy link
Author

NintyS commented Dec 9, 2023

Nah, probably you can't. But I get from CS:GO the CRC codes and they works so for now I'm good.

var (
	Mirage   uint32 = 1936772555
	Anubis   uint32 = 3934213780
	Nuke     uint32 = 4081488007
	Inferno  uint32 = 3201302029
	Ancient  uint32 = 4262714479
	Overpass uint32 = 2863184063
	Vertigo  uint32 = 970160341
)

@dankotov
Copy link

dankotov commented Dec 9, 2023

Understood! Thanks for the list. However, how do you get the map name from the demo to get the corresponding crc? header.MapName returning nil for me.

@NintyS
Copy link
Author

NintyS commented Dec 12, 2023

Sorry for delay, I didn't get notification until I open mail. AFAIK header is deprecated / returns nothing because new header is different than old one.

This is my code:
`
var mapName string
var mapMetaData ex.Map

p.RegisterNetMessageHandler(func(msg *msgs2.CSVCMsg_ServerInfo) {

	var mapCode uint32 = 0

	if strings.Contains(msg.GetMapName(), "mirage") {
		mapCode = Mirage
	}

	if strings.Contains(msg.GetMapName(), "overpass") {
		mapCode = Overpass
	}

	if strings.Contains(msg.GetMapName(), "inferno") {
		mapCode = Inferno
	}

	if strings.Contains(msg.GetMapName(), "vertigo") {
		mapCode = Vertigo
	}

	if strings.Contains(msg.GetMapName(), "anubis") {
		mapCode = Anubis
	}

	if strings.Contains(msg.GetMapName(), "nuke") {
		mapCode = Nuke
	}

	if strings.Contains(msg.GetMapName(), "ancient") {
		mapCode = Ancient
	}

	mapMetaData = ex.GetMapMetadata(msg.GetMapName(), mapCode)

	fmt.Println(mapMetaData)

	mapName = msg.GetMapName()
})`

@NintyS
Copy link
Author

NintyS commented Dec 12, 2023

It's shit but for now this is only thing I can do I guess. Maybe I will post my repo with code as a example for people.

@dankotov
Copy link

Understood! Thanks for sharing

@dankotov
Copy link

dankotov commented Dec 16, 2023

Out of curiosity, is there any reason you dont do it like this?

var mapCodes = map[string]uint32{
	"de_mirage":   1936772555,
	"de_anubis":   3934213780,
	"de_nuke":     4081488007,
	"de_inferno":  3201302029,
	"de_ancient":  4262714479,
	"de_overpass": 2863184063,
	"de_vertigo":  970160341,
}

var mapMetadata ex.Map

p.RegisterNetMessageHandler(func(msg *msgs2.CSVCMsg_ServerInfo) {
	mapName := msg.GetMapName() // change if you want mapName to be available somewhere else as well
	mapMetadata = ex.GetMapMetadata(mapName, mapCodes[mapName])
})

@NintyS
Copy link
Author

NintyS commented Dec 17, 2023

Yes, because I forgot that Key-Value dictionaries exists XD

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

3 participants