### Initialize Go Project and Install Library Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Steps to create a new Go Modules project and install the demoinfocs-golang library for CS2. ```bash mkdir my-project cd my-project go mod init my-project go get -u github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs ``` -------------------------------- ### Start Broadcasting in CS:GO Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Parsing-Broadcasts Steps to enable broadcasting and start recording a demo. Ensure the broadcast URL is correctly set. ```bash tv_enable 1; tv_broadcast_url "http://localhost:8181/broadcast" map de_dust2 tv_record bc-test; tv_broadcast 1 ``` -------------------------------- ### Run Viewmodel Settings Example Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/viewmodel-settings/README.md Execute the Go example by providing the path to a CS2 demo file as a command-line argument. Ensure the demo file is for Counter-Strike 2, as older versions will not contain viewmodel data. ```bash go run viewmodel_settings.go -demo /path/to/cs2-demo.dem ``` -------------------------------- ### Install Protobuf Go Plugin Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Install the `protoc-gen-go` plugin required for generating protobuf code. Make sure it is added to your PATH. ```bash go install google.golang.org/protobuf/cmd/protoc-gen-go@latest ``` -------------------------------- ### Install CS2 + Live Broadcast Parsing Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Use this command to get the latest version for Counter-Strike 2 and live broadcast parsing. ```bash go get -u github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs ``` -------------------------------- ### Start CS2 Server for Broadcasts Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/broadcasts/README.md Commands to start a dedicated CS2 server and enable broadcasts. Ensure the `LD_LIBRARY_PATH` is set correctly if needed. ```bash cs2 -dedicated -port 27016 +sv_setsteamaccount 0F81C7E09971B48600F6642E21183EEC +game_type 0 +game_mode 1 +sv_hibernate_when_empty 0 +map de_overpass ``` ```bash LD_LIBRARY_PATH=".../game/bin/linuxsteamrt64:$LD_LIBRARY_PATH" cs2 -dedicated -port 27016 +sv_setsteamaccount 0F81C7E09971B48600F6642E21183EEC +game_type 0 +game_mode 1 +sv_hibernate_when_empty 0 +map de_overpass ``` -------------------------------- ### Install CS:GO Parsing Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Use this command to get the version for Counter-Strike: Global Offensive parsing. ```bash go get -u github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs ``` -------------------------------- ### Sample Server Class with Properties Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/entities/README.md This example shows a detailed breakdown of a specific server class, 'CWeaponAWP', including its data table information, base classes, and a comprehensive list of its properties. ```text ServerClass: id=202 name=CWeaponAWP dataTableId=202 dataTableName=DT_WeaponAWP baseClasses: CBaseEntity CBaseAnimating CBaseAnimatingOverlay CBaseFlex CEconEntity CBaseCombatWeapon CWeaponCSBase CWeaponCSBaseGun props: m_flSimulationTime m_cellbits m_cellX m_cellY m_cellZ serveranimdata.m_flCycle m_vecOrigin m_angRotation m_fAccuracyPenalty m_bSpottedByMask.001 m_flPoseParameter.000 m_flPoseParameter.001 m_flPoseParameter.002 m_flPoseParameter.003 m_flPoseParameter.004 m_flPoseParameter.005 m_flPoseParameter.006 m_flPoseParameter.007 m_flPoseParameter.008 m_flPoseParameter.009 m_flPoseParameter.010 m_flPoseParameter.011 m_flPoseParameter.012 m_flPoseParameter.013 m_flPoseParameter.014 m_flPoseParameter.015 m_flPoseParameter.016 m_flPoseParameter.017 m_flPoseParameter.018 m_flPoseParameter.019 m_flPoseParameter.020 m_flPoseParameter.021 m_flPoseParameter.022 m_flPoseParameter.023 m_flEncodedController.000 m_flEncodedController.001 m_flEncodedController.002 m_flEncodedController.003 m_Collision.m_triggerBloat m_AnimOverlay.lengthproxy.lengthprop15 m_AnimOverlay.000.m_nSequence m_AnimOverlay.000.m_flCycle m_AnimOverlay.000.m_flPlaybackRate m_AnimOverlay.000.m_flPrevCycle m_AnimOverlay.000.m_flWeight m_AnimOverlay.000.m_flWeightDeltaRate m_AnimOverlay.000.m_nOrder m_AnimOverlay.001.m_nSequence m_AnimOverlay.001.m_flCycle m_AnimOverlay.001.m_flPlaybackRate m_AnimOverlay.001.m_flPrevCycle m_AnimOverlay.001.m_flWeight m_AnimOverlay.001.m_flWeightDeltaRate m_AnimOverlay.001.m_nOrder m_AnimOverlay.002.m_nSequence m_AnimOverlay.002.m_flCycle m_AnimOverlay.002.m_flPlaybackRate m_AnimOverlay.002.m_flPrevCycle m_AnimOverlay.002.m_flWeight m_AnimOverlay.002.m_flWeightDeltaRate m_AnimOverlay.002.m_nOrder m_AnimOverlay.003.m_nSequence m_AnimOverlay.003.m_flCycle m_AnimOverlay.003.m_flPlaybackRate m_AnimOverlay.003.m_flPrevCycle m_AnimOverlay.003.m_flWeight m_AnimOverlay.003.m_flWeightDeltaRate m_AnimOverlay.003.m_nOrder m_AnimOverlay.004.m_nSequence m_AnimOverlay.004.m_flCycle m_AnimOverlay.004.m_flPlaybackRate m_AnimOverlay.004.m_flPrevCycle m_AnimOverlay.004.m_flWeight m_AnimOverlay.004.m_flWeightDeltaRate m_AnimOverlay.004.m_nOrder m_AnimOverlay.005.m_nSequence m_AnimOverlay.005.m_flCycle m_AnimOverlay.005.m_flPlaybackRate m_AnimOverlay.005.m_flPrevCycle m_AnimOverlay.005.m_flWeight m_AnimOverlay.005.m_flWeightDeltaRate m_AnimOverlay.005.m_nOrder m_AnimOverlay.006.m_nSequence m_AnimOverlay.006.m_flCycle m_AnimOverlay.006.m_flPlaybackRate m_AnimOverlay.006.m_flPrevCycle m_AnimOverlay.006.m_flWeight m_AnimOverlay.006.m_flWeightDeltaRate m_AnimOverlay.006.m_nOrder m_AnimOverlay.007.m_nSequence m_AnimOverlay.007.m_flCycle m_AnimOverlay.007.m_flPlaybackRate m_AnimOverlay.007.m_flPrevCycle m_AnimOverlay.007.m_flWeight m_AnimOverlay.007.m_flWeightDeltaRate m_AnimOverlay.007.m_nOrder m_AnimOverlay.008.m_nSequence m_AnimOverlay.008.m_flCycle m_AnimOverlay.008.m_flPlaybackRate m_AnimOverlay.008.m_flPrevCycle m_AnimOverlay.008.m_flWeight m_AnimOverlay.008.m_flWeightDeltaRate m_AnimOverlay.008.m_nOrder m_AnimOverlay.009.m_nSequence m_AnimOverlay.009.m_flCycle m_AnimOverlay.009.m_flPlaybackRate m_AnimOverlay.009.m_flPrevCycle m_AnimOverlay.009.m_flWeight m_AnimOverlay.009.m_flWeightDeltaRate m_AnimOverlay.009.m_nOrder m_AnimOverlay.010.m_nSequence m_AnimOverlay.010.m_flCycle m_AnimOverlay.010.m_flPlaybackRate m_AnimOverlay.010.m_flPrevCycle m_AnimOverlay.010.m_flWeight m_AnimOverlay.010.m_flWeightDeltaRate m_AnimOverlay.010.m_nOrder m_AnimOverlay.011.m_nSequence m_AnimOverlay.011.m_flCycle m_AnimOverlay.011.m_flPlaybackRate m_AnimOverlay.011.m_flPrevCycle m_AnimOverlay.011.m_flWeight m_AnimOverlay.011.m_flWeightDeltaRate m_AnimOverlay.011.m_nOrder m_AnimOverlay.012.m_nSequence m_AnimOverlay.012.m_flCycle m_AnimOverlay.012.m_flPlaybackRate m_AnimOverlay.012.m_flPrevCycle m_AnimOverlay.012.m_flWeight m_AnimOverlay.012.m_flWeightDeltaRate m_AnimOverlay.012.m_nOrder m_AnimOverlay.013.m_nSequence m_AnimOverlay.013.m_flCycle m_AnimOverlay.013.m_flPlaybackRate m_AnimOverlay.013.m_flPrevCycle ``` -------------------------------- ### Run Nade Trajectory Example Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/nade-trajectories/README.md Execute the nade trajectory example using the Go command-line tool. Specify the path to the demo file and redirect the output to a JPEG file. This command generates an image showing grenade trajectories for the first five rounds of the match. ```bash go run nade_trajectories.go -demo /path/to/demo > out.jpg ``` -------------------------------- ### Run Unit Tests Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Execute the project's unit tests using the provided script or the standard Go test command. The `-short` flag is used to run tests that don't require extensive setup or resources. ```bash scripts/unit-tests.sh ``` ```bash go test -short ./... ``` -------------------------------- ### Run Regression Tests Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Execute the full regression suite by downloading test demos and running the provided script. Ensure Git LFS and 7z are installed and in your PATH. ```bash scripts/regression-tests.sh ``` -------------------------------- ### Configure Debugging with LDFLAGS Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Customize default debugging behavior by using Go's `ldflags` parameter. This example shows how to additionally print all server classes with their properties. ```bash go run -tags debugdemoinfocs -ldflags="-X 'github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs.debugServerClasses=YES'" examples/print-events/print_events.go -demo example.dem ``` -------------------------------- ### System Under Test: collectKills function Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/mocking/README.md This function takes a demoinfocs.Parser and returns a slice of events.Kill and an error. It's the target for our mocking examples. ```go import ( dem "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs" events "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/events" ) func collectKills(parser dem.Parser) (kills []events.Kill, err error) { ... } ``` -------------------------------- ### Link Git Hooks Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Install optional pre-commit and pre-push git hooks by running this script. These hooks include interface checks, code building, unit tests, and regression tests. ```bash scripts/git-hooks/link-git-hooks.sh ``` -------------------------------- ### Update demoinfocs-golang Dependency Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 Use 'go get -u' to update the demoinfocs-golang library to the latest version, ensuring you are using v2. ```bash go get -u github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs ``` -------------------------------- ### Generate Protobuf Code Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Generate protobuf code within the `msg` package after installing the necessary tools. On Windows, run this command from CMD, not Bash. ```bash go generate ./msg ``` -------------------------------- ### Print All Server Classes and Properties Source: https://github.com/markus-wa/demoinfocs-golang/wiki/CS2-Server-Classes Use this command to print out all server classes and their properties. Ensure you have the necessary build tags and flags set. ```bash $ go run -tags debugdemoinfocs -ldflags '-X github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs.debugServerClasses=YES' examples/print-events/print_events.go -demo test/cs-demos/default.dem ``` -------------------------------- ### Sample Server Class Output Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/entities/README.md This is a sample output showing the structure of server classes found in a demo file. Each line lists the server class ID and its name. ```text ServerClass: id=0 name=CAI_BaseNPC ServerClass: id=1 name=CAK47 ServerClass: id=2 name=CBaseAnimating ServerClass: id=3 name=CBaseAnimatingOverlay ServerClass: id=4 name=CBaseAttributableItem ServerClass: id=5 name=CBaseButton ServerClass: id=6 name=CBaseCombatCharacter ServerClass: id=7 name=CBaseCombatWeapon ServerClass: id=8 name=CBaseCSGrenade ServerClass: id=9 name=CBaseCSGrenadeProjectile ServerClass: id=10 name=CBaseDoor ServerClass: id=11 name=CBaseEntity ServerClass: id=12 name=CBaseFlex ServerClass: id=13 name=CBaseGrenade ServerClass: id=14 name=CBaseParticleEntity ServerClass: id=15 name=CBasePlayer ServerClass: id=16 name=CBasePropDoor ServerClass: id=17 name=CBaseTeamObjectiveResource ServerClass: id=18 name=CBaseTempEntity ServerClass: id=19 name=CBaseToggle ServerClass: id=20 name=CBaseTrigger ServerClass: id=21 name=CBaseViewModel ServerClass: id=22 name=CBaseVPhysicsTrigger ServerClass: id=23 name=CBaseWeaponWorldModel ServerClass: id=24 name=CBeam ServerClass: id=25 name=CBeamSpotlight ServerClass: id=26 name=CBoneFollower ServerClass: id=27 name=CBreakableProp ServerClass: id=28 name=CBreakableSurface ServerClass: id=29 name=CC4 ServerClass: id=30 name=CCascadeLight ServerClass: id=31 name=CChicken ServerClass: id=32 name=CColorCorrection ServerClass: id=33 name=CColorCorrectionVolume ServerClass: id=34 name=CCSGameRulesProxy ServerClass: id=35 name=CCSPlayer ServerClass: id=36 name=CCSPlayerResource ServerClass: id=37 name=CCSRagdoll ServerClass: id=38 name=CCSTeam ServerClass: id=39 name=CDEagle ServerClass: id=40 name=CDecoyGrenade ServerClass: id=41 name=CDecoyProjectile ServerClass: id=42 name=CDynamicLight ServerClass: id=43 name=CDynamicProp ServerClass: id=44 name=CEconEntity ServerClass: id=45 name=CEmbers ServerClass: id=46 name=CEntityDissolve ServerClass: id=47 name=CEntityFlame ServerClass: id=48 name=CEntityFreezing ServerClass: id=49 name=CEntityParticleTrail ServerClass: id=50 name=CEnvAmbientLight ServerClass: id=51 name=CEnvDetailController ServerClass: id=52 name=CEnvDOFController ServerClass: id=53 name=CEnvParticleScript ServerClass: id=54 name=CEnvProjectedTexture ServerClass: id=55 name=CEnvQuadraticBeam ServerClass: id=56 name=CEnvScreenEffect ServerClass: id=57 name=CEnvScreenOverlay ServerClass: id=58 name=CEnvTonemapController ServerClass: id=59 name=CEnvWind ServerClass: id=60 name=CFEPlayerDecal ServerClass: id=61 name=CFireCrackerBlast ServerClass: id=62 name=CFireSmoke ServerClass: id=63 name=CFireTrail ServerClass: id=64 name=CFish ServerClass: id=65 name=CFlashbang ServerClass: id=66 name=CFogController ServerClass: id=67 name=CFootstepControl ServerClass: id=68 name=CFunc_Dust ServerClass: id=69 name=CFunc_LOD ServerClass: id=70 name=CFuncAreaPortalWindow ServerClass: id=71 name=CFuncBrush ServerClass: id=72 name=CFuncConveyor ServerClass: id=73 name=CFuncLadder ServerClass: id=74 name=CFuncMonitor ServerClass: id=75 name=CFuncMoveLinear ServerClass: id=76 name=CFuncOccluder ServerClass: id=77 name=CFuncReflectiveGlass ServerClass: id=78 name=CFuncRotating ServerClass: id=79 name=CFuncSmokeVolume ServerClass: id=80 name=CFuncTrackTrain ServerClass: id=81 name=CGameRulesProxy ServerClass: id=82 name=CHandleTest ServerClass: id=83 name=CHEGrenade ServerClass: id=84 name=CHostage ServerClass: id=85 name=CHostageCarriableProp ServerClass: id=86 name=CIncendiaryGrenade ServerClass: id=87 name=CInferno ServerClass: id=88 name=CInfoLadderDismount ServerClass: id=89 name=CInfoOverlayAccessor ServerClass: id=90 name=CItem_Healthshot ServerClass: id=91 name=CKnife ServerClass: id=92 name=CKnifeGG ServerClass: id=93 name=CLightGlow ServerClass: id=94 name=CMaterialModifyControl ServerClass: id=95 name=CMolotovGrenade ServerClass: id=96 name=CMolotovProjectile ServerClass: id=97 name=CMovieDisplay ServerClass: id=98 name=CParticleFire ServerClass: id=99 name=CParticlePerformanceMonitor ServerClass: id=100 name=CParticleSystem ServerClass: id=101 name=CPhysBox ServerClass: id=102 name=CPhysBoxMultiplayer ServerClass: id=103 name=CPhysicsProp ServerClass: id=104 name=CPhysicsPropMultiplayer ServerClass: id=105 name=CPhysMagnet ServerClass: id=106 name=CPlantedC4 ServerClass: id=107 name=CPlasma ServerClass: id=108 name=CPlayerResource ServerClass: id=109 name=CPointCamera ServerClass: id=110 name=CPointCommentaryNode ServerClass: id=111 name=CPoseController ServerClass: id=112 name=CPostProcessController ServerClass: id=113 name=CPrecipitation ``` -------------------------------- ### Fix: player.Armor is a function Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 The 'Armor' field for a player is now a method. Call 'player.Armor()' to get the armor value. ```go ./csminify.go:158:5: cannot use player.Armor (type func() int) as type int in field value change player.Armor -> player.Armor() ``` -------------------------------- ### Print CS:GO Server Classes and Properties Source: https://github.com/markus-wa/demoinfocs-golang/wiki/CS:GO-Server-Classes Use this command to print all server classes and their properties to the console. Ensure you have the debug build flags enabled. ```bash go run -tags debugdemoinfocs -ldflags '-X github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs.debugServerClasses=YES' examples/print-events/print_events.go -demo test/cs-demos/default.dem ``` -------------------------------- ### Parse Live Broadcast with Go Client Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/broadcasts/README.md Run the Go client to connect to and parse the live broadcast stream. Replace `` with the actual broadcast token. ```bash go run broadcasts.go -url "http://localhost:8080/" ``` -------------------------------- ### Configure NetMessageCreator for Custom Messages Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/net-messages/README.md Add custom net-message creators to `ParserConfig.AdditionalNetMessageCreators` to parse messages not handled by default. This example shows how to add support for `svc_BSPDecal` messages. ```go import ( "google.golang.org/protobuf/proto" dem "github.com/markus-wa/demoinfocs-golang" "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/msg" ) cfg := dem.DefaultParserConfig cfg.AdditionalNetMessageCreators = map[int]dem.NetMessageCreator{ int(msg.SVC_Messages_svc_BSPDecal): func() proto.Message { return new(msg.CSVCMsg_BSPDecal) }, } p := dem.NewParserWithConfig(f, cfg) ``` -------------------------------- ### List Server Classes Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/entities/README.md This output lists available server classes. Remove the 'grep ServerClass' command to see all properties associated with each class. ```text ServerClass: id=239 name=CWeaponUMP45 ServerClass: id=240 name=CWeaponUSP ServerClass: id=241 name=CWeaponXM1014 ServerClass: id=242 name=CWorld ServerClass: id=243 name=DustTrail ServerClass: id=244 name=MovieExplosion ServerClass: id=245 name=ParticleSmokeGrenade ServerClass: id=246 name=RocketTrail ServerClass: id=247 name=SmokeTrail ServerClass: id=248 name=SporeExplosion ServerClass: id=249 name=SporeTrail ``` -------------------------------- ### Fix: Undefined demoinfocs.IParticipants Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 The interface 'IParticipants' has been renamed. Change 'demoinfocs.IParticipants' to 'demoinfocs.Participants'. ```go ./csminify.go:110:17: undefined: demoinfocs.IParticipants change demoinfocs.IParticipants -> demoinfocs.Participants ``` -------------------------------- ### Fix: Undefined demoinfocs.IParser Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 The interface 'IParser' has been renamed. Change 'demoinfocs.IParser' to 'demoinfocs.Parser'. ```go ./csminify.go:110:17: undefined: demoinfocs.IParser change demoinfocs.IParser -> demoinfocs.Parser ``` -------------------------------- ### Fix: player.Entity.PropertiesI undefined Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 The method 'PropertiesI' on 'sendtables.Entity' has been renamed. Use 'player.Entity.Properties()' instead. ```go ./csminify.go:157:23: player.Entity.PropertiesI undefined (type sendtables.Entity has no field or method PropertiesI) change player.Entity.PropertiesI() -> player.Entity.Properties() ``` -------------------------------- ### Go Benchmark Output Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Raw output from Go's benchmarking tool, showing performance metrics for parsing demos concurrently, reading from disk, and reading from memory. ```text $ go test -run _NONE_ -bench . -benchtime 30s -benchmem -concurrentdemos 8 goos: windows goarch: amd64 pkg: github.com/markus-wa/demoinfocs-golang BenchmarkDemoInfoCs-8 50 894500010 ns/op 257610127 B/op 914355 allocs/op BenchmarkInMemory-8 50 876279984 ns/op 257457271 B/op 914143 allocs/op BenchmarkConcurrent-8 20 2058303680 ns/op 2059386582 B/op 7313145 allocs/op --- BENCH: BenchmarkConcurrent-8 demoinfocs_test.go:315: Running concurrency benchmark with 8 demos demoinfocs_test.go:315: Running concurrency benchmark with 8 demos PASS ok github.com/markus-wa/demoinfocs-golang 134.244s ``` -------------------------------- ### Create Fake Demo File from Broadcast Data Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Parsing-Broadcasts Command to concatenate necessary demo file parts to create a playable fake demo. This method assumes a correct map demo is available for the header. ```bash { head -c 1077 ~/path/to/demo_FROM_CORRECT_MAP.dem; tail -c +6 0_start; for i in $(ls *_full | cut -c 1); do cat ${i}_full ${i}_delta; done; } > fake.dem ``` -------------------------------- ### Fix: Cannot use demoinfocs.Parser as *demoinfocs.Parser Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 When assigning a 'demoinfocs.Parser' type, ensure you are not trying to use it as a pointer ('*demoinfocs.Parser') if the function expects the value type. ```go ./csminify.go:86:28: cannot use p (type demoinfocs.Parser) as type *demoinfocs.Parser in assignment: *demoinfocs.Parser is pointer to interface, not interface change *demoinfocs.Parser -> demoinfocs.Parser ``` -------------------------------- ### Fix: Undefined demoinfocs.IGameState Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 The interface 'IGameState' has been renamed. Change 'demoinfocs.IGameState' to 'demoinfocs.GameState'. ```go ./csminify.go:110:17: undefined: demoinfocs.IGameState change demoinfocs.IGameState -> demoinfocs.GameState ``` -------------------------------- ### Fix: Cannot use demoinfocs.GameState as *demoinfocs.GameState Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 When assigning a 'demoinfocs.GameState' type, ensure you are not trying to use it as a pointer ('*demoinfocs.GameState') if the function expects the value type. ```go ./csminify.go:86:28: cannot use gs (type demoinfocs.GameState) as type *demoinfocs.GameState in assignment: *demoinfocs.GameState is pointer to interface, not interface change *demoinfocs.GameState -> demoinfocs.GameState ``` -------------------------------- ### Sample Output of Viewmodel Settings Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/viewmodel-settings/README.md The output displays player names along with their extracted viewmodel offset (X, Y, Z coordinates) and field of view (FOV). Note that viewmodel settings are only available in CS2 demos; CS:GO demos will show zero values. ```text Player viewmodels: degster: Viewmodel Offset=(2.5, 0.0, -1.5), FOV=60.0 kyxsan: Viewmodel Offset=(1.0, 1.0, -1.0), FOV=60.0 NiKo: Viewmodel Offset=(-1.0, 1.5, -2.0), FOV=60.0 SOMEBODY: Viewmodel Offset=(2.5, 2.0, -2.0), FOV=60.0 Summer: Viewmodel Offset=(2.5, 0.0, -1.5), FOV=60.0 L1haNg: Viewmodel Offset=(2.5, 0.0, -1.5), FOV=60.0 ChildKing: Viewmodel Offset=(2.5, 1.0, -1.5), FOV=60.0 TeSeS: Viewmodel Offset=(2.5, 0.0, -1.5), FOV=60.0 Magisk: Viewmodel Offset=(2.5, 0.0, -1.5), FOV=60.0 kaze: Viewmodel Offset=(2.5, 0.0, -1.5), FOV=60.0 ``` -------------------------------- ### Enable Debug Logging for Server Classes Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/entities/README.md Use the `debugdemoinfocs` build tag and set `debugServerClasses=YES` with ldflags to enable detailed logging of server classes. This is useful for inspecting game entity structures. ```bash go run myprogram.go -tags debugdemoinfocs -ldflags '-X github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs.debugServerClasses=YES' | grep ServerClass ``` -------------------------------- ### Fix: player.Entity.FindPropertyI undefined Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 The method 'FindPropertyI' on 'sendtables.Entity' has been renamed. Use 'player.Entity.Property()' instead. ```go ./csminify.go:157:23: player.Entity.FindPropertyI undefined (type sendtables.Entity has no field or method FindPropertyI) change player.Entity.FindPropertyI() -> player.Entity.Property() ``` -------------------------------- ### Fix: Cannot use demoinfocs.Participants as *demoinfocs.Participants Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 When assigning a 'demoinfocs.Participants' type, ensure you are not trying to use it as a pointer ('*demoinfocs.Participants') if the function expects the value type. ```go ./csminify.go:86:28: cannot use p (type demoinfocs.Participants) as type *demoinfocs.Participants in assignment: *demoinfocs.Participants is pointer to interface, not interface change *demoinfocs.Participants -> demoinfocs.Participants ``` -------------------------------- ### Fix: Undefined sendtables.IProperty Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 The interface 'IProperty' has been renamed. Change 'sendtables.IProperty' to 'sendtables.Property'. ```go ./csminify.go:110:17: undefined: sendtables.IProperty change sendtables.IProperty -> sendtables.Property ``` -------------------------------- ### Configure and Enable Broadcast Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/examples/broadcasts/README.md Console commands to set the broadcast delay, URL, and enable broadcasting on the CS2 server. The URL will include a token. ```bash tv_delay 0; tv_broadcast_url "http://localhost:8080"; tv_broadcast 1 ``` -------------------------------- ### Fix: e.Weapon.Weapon undefined Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 The 'Weapon' field within 'common.Equipment' has been renamed. Use 'Type' instead of 'Weapon' to access the weapon type. ```go ./events.go:104:46: e.Weapon.Weapon undefined (type *common.Equipment has no field or method Weapon) change e.Weapon.Weapon -> e.Weapon.Type ``` -------------------------------- ### Register Generic Game Event Handler in Go Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/docs/game-events.md Listen to all game events by registering a handler for `GenericGameEvent`. This is useful for general event monitoring during demo parsing. ```go parser.RegisterEventHandler(func(event events.GenericGameEvent) { fmt.Println(event.Name, event.Data) }) ``` -------------------------------- ### Fix: player.SteamID undefined Source: https://github.com/markus-wa/demoinfocs-golang/wiki/Upgrading-from-v1.x-to-v2.0.0 The 'SteamID' field for a player has been renamed. Use 'player.SteamID64' to access the player's 64-bit Steam ID. ```go ./csminify.go:157:16: player.SteamID undefined (type *common.Player has no field or method SteamID) change player.SteamID -> player.SteamID64 ``` -------------------------------- ### Handle Game Events with Go Source: https://github.com/markus-wa/demoinfocs-golang/blob/master/README.md Register an event handler to process specific game events, such as kills, by providing a callback function. Ensure the demo file path is correct and handle potential parsing errors. ```go package main import ( "log" demoinfocs "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs" events "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/events" ) func onKill(kill events.Kill) { var hs string if kill.IsHeadshot { hs = " (HS)" } var wallBang string if kill.PenetratedObjects > 0 { wallBang = " (WB)" } log.Printf("%s <%v%s%s> %s\n", kill.Killer, kill.Weapon, hs, wallBang, kill.Victim) } func main() { err := demoinfocs.ParseFile("/path/to/demo.dem", func(p demoinfocs.Parser) error { p.RegisterEventHandler(onKill) return nil }) if err != nil { log.Panic("failed to parse demo: ", err) } } ```