+ if(p.cvar_cl_allow_uid2name == 1 || clienttype(p) == CLIENTTYPE_BOT)
+ db_put(playerstats_db, sprintf("%s:_netname", p.playerstats_id), p.netname);
+
+ if(teamplay)
+ db_put(playerstats_db, sprintf("%s:_team", p.playerstats_id), ftos(p.team));
+
+ if(p.alivetime > 0)
+ PlayerStats_Event(p, PLAYERSTATS_JOINS, 1);
+
+ strunzone(p.playerstats_id);
+ p.playerstats_id = string_null;
+}
+
+void PlayerStats_Accuracy(entity p)
+{
+ entity a, w;
+ a = p.accuracy;
+ float i;
+
+ for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+ {
+ w = get_weaponinfo(i);
+
+ PlayerStats_Event(p, strcat("acc-", w.netname, "-hit"), a.accuracy_hit[i-1]);
+ PlayerStats_Event(p, strcat("acc-", w.netname, "-fired"), a.accuracy_fired[i-1]);
+
+ PlayerStats_Event(p, strcat("acc-", w.netname, "-cnt-hit"), a.accuracy_cnt_hit[i-1]);
+ PlayerStats_Event(p, strcat("acc-", w.netname, "-cnt-fired"), a.accuracy_cnt_fired[i-1]);
+
+ PlayerStats_Event(p, strcat("acc-", w.netname, "-frags"), a.accuracy_frags[i-1]);
+ }
+}
+
+void PlayerStats_EndMatch(float finished)
+{
+ entity p, winner;
+ winner = PlayerScore_Sort(score_dummyfield);
+ FOR_EACH_PLAYER(p)
+ {
+ PlayerScore_PlayerStats(p);
+ PlayerStats_Accuracy(p);
+ PlayerStats_Event(p, PLAYERSTATS_SCOREBOARD_VALID, 1);
+ if(finished)
+ {
+ PlayerStats_Event(p, PLAYERSTATS_WINS, p.winning);
+ PlayerStats_Event(p, PLAYERSTATS_MATCHES, 1);
+ PlayerStats_Event(p, PLAYERSTATS_RANK, p.score_dummyfield);
+ }
+ }