NS2CDT / NS2Plus

NS2+ mod for Natural Selection 2
5 stars 7 forks source link

Broken stats if player left before game end #23

Closed Azperin closed 5 years ago

Azperin commented 5 years ago

This happen in exported file (option savestats on) if player left the game before it's ends: "status":[null,11.01415566355,null,null,null,null,null,382.36842441931], "weapons":{ "152":{ "hits":11, "kills":1, "misses":71, "onosHits":0, "pdmg":106.5, "sdmg":0, "teamNumber":1 }, "153":{ "hits":1, "kills":1, "misses":1, "onosHits":0, "pdmg":5, "sdmg":0, "teamNumber":1 } It was fixed in KillFeed (https://forums.unknownworlds.com/discussion/140081/ns2-stats-export), but still exist in "status" and "weapons"

Azperin commented 5 years ago

Would you please test if it's work, one of our players provide this code

local status = statusGrouping[self:GetPlayerStatusDesc()] ~= nil and statusGrouping[self:GetPlayerStatusDesc()] or self:GetPlayerStatusDesc()
if statusRoot[status] == nil then
statusRoot[status] = 0
end
statusRoot[status] = statusRoot[status] + deltaTime

to change on

local status = statusGrouping[self:GetPlayerStatusDesc()] ~= nil and function() return statusGrouping[self:GetPlayerStatusDesc()] end or self:GetPlayerStatusDesc()
if statusRoot[status()] == nil then
statusRoot[status()] = 0
end
statusRoot[status()] = statusRoot[status()] + deltaTime
Azperin commented 5 years ago

Because of this problem, commander statistics are also not saved. SteamID of this player is not even appears in "MarineCommStats"

"MarineCommStats":{},

"PlayerStats":{
  "64882105":{
    "1":{
      "assists":1,
      "commanderTime":397.49053122662,
      "deaths":0,
      "hits":0,
      "kills":3,
      "killstreak":3,
      "misses":0,
      "onosHits":0,
      "playerDamage":362.5,
      "score":13,
      "structureDamage":0,
      "timeBuilding":0,
      "timePlayed":397.49053122662
    },
    "lastTeam":1,
    "status":[null,null,null,null,397.49053122662],
  },
}