File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -812,14 +812,12 @@ This example prints the life-cycle of all AWPs during the game - i.e. who picked
812812
813813``` go
814814p.RegisterEventHandler (func (events.DataTablesParsed ) {
815- // DataTablesParsed has been sent out, register entity-creation handler
816- p.ServerClasses ().FindByName (" CWeaponAWP" ).OnEntityCreated (func (entity *st.Entity ) {
817- // Register update-hander on the owning entity (player who's holding the AWP)
818- entity.FindPropertyI (" m_hOwnerEntity" ).OnUpdate (func (val st.PropertyValue ) {
819- owner := p.GameState ().Participants ().FindByHandle (val.IntVal )
820- if owner != nil {
815+ p.ServerClasses ().FindByName (" CWeaponAWP" ).OnEntityCreated (func (ent st.Entity ) {
816+ ent.Property (" m_hOwnerEntity" ).OnUpdate (func (val st.PropertyValue ) {
817+ x := p.GameState ().Participants ().FindByHandle (val.IntVal )
818+ if x != nil {
821819 var prev string
822- prevHandle := entity. FindPropertyI (" m_hPrevOwner" ).Value ().IntVal
820+ prevHandle := ent. Property (" m_hPrevOwner" ).Value ().IntVal
823821 prevPlayer := p.GameState ().Participants ().FindByHandle (prevHandle)
824822 if prevPlayer != nil {
825823 if prevHandle != val.IntVal {
@@ -830,7 +828,7 @@ p.RegisterEventHandler(func(events.DataTablesParsed) {
830828 } else {
831829 prev = " a brand new"
832830 }
833- fmt.Printf (" %s picked up %s AWP (#%d )\n " , owner .Name , prev, entity .ID ())
831+ fmt.Printf (" %s picked up %s AWP (#%d )\n " , x .Name , prev, ent .ID ())
834832 }
835833 })
836834 })
You can’t perform that action at this time.
0 commit comments