update
This commit is contained in:
parent
aa208a14d4
commit
e41bb63fbd
35
main.go
35
main.go
@ -180,7 +180,11 @@ func main() {
|
||||
})
|
||||
|
||||
p.RegisterEventHandler(func(e events.Kill) {
|
||||
if e.Killer != nil && e.Killer.SteamID64 != e.Victim.SteamID64 {
|
||||
if e.Killer != nil && e.Victim != nil && e.Killer.SteamID64 != e.Victim.SteamID64 {
|
||||
killerTeam := e.Killer.Team
|
||||
victimTeam := e.Victim.Team
|
||||
|
||||
if killerTeam != victimTeam && killerTeam != common.TeamSpectators {
|
||||
stat := getOrCreate(*e.Killer)
|
||||
stat.Kills++
|
||||
if e.IsHeadshot {
|
||||
@ -207,10 +211,13 @@ func main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if e.Victim != nil {
|
||||
stat := getOrCreate(*e.Victim)
|
||||
stat.Deaths++
|
||||
}
|
||||
|
||||
if e.Assister != nil {
|
||||
stat := getOrCreate(*e.Assister)
|
||||
stat.Assists++
|
||||
@ -227,7 +234,6 @@ func main() {
|
||||
p.RegisterEventHandler(func(e events.PlayerHurt) {
|
||||
if e.Attacker != nil && e.Attacker != e.Player {
|
||||
stat := getOrCreate(*e.Attacker)
|
||||
stat.TotalDamage += e.HealthDamage
|
||||
if e.Weapon != nil {
|
||||
switch e.Weapon.Type {
|
||||
case common.EqHE, common.EqMolotov, common.EqIncendiary:
|
||||
@ -301,8 +307,29 @@ func main() {
|
||||
|
||||
for _, stat := range playerStats {
|
||||
sid, _ := parseSteamID(stat.SteamID)
|
||||
if team, ok := teamHistory[1][sid]; ok {
|
||||
stat.Team = team
|
||||
lastTeam := ""
|
||||
lastRound := 0
|
||||
|
||||
for roundNum, roundTeams := range teamHistory {
|
||||
if team, ok := roundTeams[sid]; ok && roundNum > lastRound {
|
||||
lastTeam = team
|
||||
lastRound = roundNum
|
||||
}
|
||||
}
|
||||
|
||||
stat.Team = lastTeam
|
||||
}
|
||||
|
||||
for _, player := range p.GameState().Participants().All() {
|
||||
sid := player.SteamID64
|
||||
stat, ok := playerStats[sid]
|
||||
if !ok || player.Entity == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
val, ok := player.Entity.PropertyValue("m_pActionTrackingServices.m_iDamage")
|
||||
if ok {
|
||||
stat.TotalDamage = val.Int()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
parser_cs2-linux
BIN
parser_cs2-linux
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user