File tree 1 file changed +6
-8
lines changed
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
812
812
813
813
``` go
814
814
p.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 {
821
819
var prev string
822
- prevHandle := entity. FindPropertyI (" m_hPrevOwner" ).Value ().IntVal
820
+ prevHandle := ent. Property (" m_hPrevOwner" ).Value ().IntVal
823
821
prevPlayer := p.GameState ().Participants ().FindByHandle (prevHandle)
824
822
if prevPlayer != nil {
825
823
if prevHandle != val.IntVal {
@@ -830,7 +828,7 @@ p.RegisterEventHandler(func(events.DataTablesParsed) {
830
828
} else {
831
829
prev = " a brand new"
832
830
}
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 ())
834
832
}
835
833
})
836
834
})
You can’t perform that action at this time.
0 commit comments