
   /*
   *
   * Endround Stats
   *  by JustinHoMi
   *
   */
   #include <amxmod>
   #include <csstats>
   new kills[32] = {0,...}        // total map kills
   new deaths[32] = {0,...}    // total map deaths
   new ct_kills = 0
   new t_kills = 0
   new ct_deaths = 0
   new t_deaths = 0
   new ct_score = 0
   new t_score = 0
   new tot_ct_shots = 0
   new tot_t_shots = 0
   new tot_ct_hits = 0
   new tot_t_hits = 0
   public round_end() {
       /* get winning team */
       new msg[32]
       read_data(2,msg,32)
       if(containi(msg,"ct") != -1)
           ct_score++
       else if(containi(msg,"ter") != -1)
           t_score++
       new plist[32],pnum
       get_players(plist,pnum)
       /* most disruptive (most dmg) */
       new dis_dmg = 0        // total damage
       new dis_id = 0        // user id
       new vstats[32][8]
       new bodyhits[8]        // tmp var
       for(new i=0; i<pnum; ++i){
           get_user_vstats(plist[i],0,vstats[plist[i]],bodyhits)
           if(vstats[plist[i]][6] > dis_dmg){
               dis_dmg = vstats[plist[i]][6]
               dis_id = plist[i]
           }
       }
       new dis_name[33]
       get_user_name(dis_id,dis_name,32)
       new      Float:dis_acc      =      float(vstats[dis_id][5])      /
   float(vstats[dis_id][4]) * 100.0
       new    Float:dis_eff    =   (float(kills[dis_id])   *   100.0)   /
   (float(kills[dis_id]) + float(deaths[dis_id]))
       /* best score */
       new sco_id = 0
       new sco_kills = 0
       new lstats[32][8]
       for(new i=0; i<pnum; i++){
           get_user_rstats(plist[i],lstats[plist[i]],bodyhits);
           if(lstats[plist[i]][0] > sco_kills){
               sco_id = plist[i]
               sco_kills = lstats[plist[i]][0]
           }
       }
       new sco_name[33]
       get_user_name(sco_id,sco_name,32)
       new      Float:sco_acc      =      float(vstats[sco_id][5])      /
   float(vstats[sco_id][4]) * 100.0
       new sco_hs = vstats[sco_id][2]
       new    Float:sco_eff    =   (float(kills[sco_id])   *   100.0)   /
   (float(kills[sco_id]) + float(deaths[sco_id]))
       /* total stats */
       new tot_stats[8], tot_kills=0, tot_hits=0, tot_shots=0
       for(new i=0; i<pnum; i++){
           get_user_rstats(plist[i],tot_stats,bodyhits)
           tot_kills += tot_stats[0]
           tot_hits += tot_stats[5]
           tot_shots += tot_stats[4]
       }
       /* ct stats */
       new ct_plist[32],ct_pnum,ct_hits=0,ct_shots=0,ct_stats[8]
       get_players(ct_plist,ct_pnum,"e","CT")
       for(new i=0; i<ct_pnum; i++){
           get_user_vstats(ct_plist[i],0,ct_stats,bodyhits)
           ct_hits += ct_stats[5]
           ct_shots += ct_stats[4]
       }
       tot_ct_hits += ct_hits
       tot_ct_shots += ct_shots
       new  Float:ct_acc  =  float(tot_ct_hits)  /  float(tot_ct_shots) *
   100.0
       new  Float:ct_eff = (float(ct_kills) * 100.0) / (float(ct_kills) +
   float(ct_deaths))
       /* t stats */
       new t_plist[32],t_pnum,t_hits=0,t_shots=0,t_stats[8]
       get_players(t_plist,t_pnum,"e","TERRORIST")
       for(new i=0; i<t_pnum; i++){
           get_user_vstats(t_plist[i],0,t_stats,bodyhits)
           t_hits += t_stats[5]
           t_shots += t_stats[4]
       }
       tot_t_hits += t_hits
       tot_t_shots += t_shots
       new  Float:tot_t_acc  =  float(tot_t_hits)  / float(tot_t_shots) *
   100.0
       new  Float:t_eff  =  (float(t_kills)  * 100.0) / (float(t_kills) +
   float(t_deaths))
       /* output */
       new p = '%'
       set_hudmessage(100, 200, 0, 0.05, 0.55, 0, 0.1, 12.0, 0.1, 0.2, 3)
       show_hudmessage(0,"Most  Disruptive:  %s^n%i  hit(s)  /  %i dmg --
   %.2f%c  eff.  /  %.2f%c  acc.^nBest  Score:  %s^n%i kill(s) / %i hs --
   %.2f%c  eff.  /  %.2f%c  acc.^n^n^nTERRORIST %i / eff.: %.2f%c / acc.:
   %.2f%c^nCT  %i  / eff. %.2f%c / acc.: %.2f%c^nTotal kills: %i Hits: %i
   Shots:
   %i",dis_name,vstats[dis_id][5],dis_dmg,dis_eff,p,dis_acc,p,sco_name,sc
   o_kills,sco_hs,sco_eff,p,sco_acc,p,t_score,t_eff,p,tot_t_acc,p,ct_scor
   e,ct_eff,p,ct_acc,p,tot_kills,tot_hits,tot_shots)
       return PLUGIN_CONTINUE
   }
   /* keep track of total kills and deaths */
   public deathmsg_event() {
       new killer = read_data(1)
       new victim = read_data(2)
       if (killer != victim && killer)    {
           kills[killer]++
           deaths[victim]++
           if(get_user_team(killer) == 1) {
               t_kills++
               ct_deaths++
           }
           else if(get_user_team(killer) == 2)    {
               ct_kills++
               t_deaths++
           }
       }
       return PLUGIN_CONTINUE
   }
   /* initialize kills & deaths for new player */
   public client_connect(id) {
       kills[id] = 0
       deaths[id] =0
       return PLUGIN_CONTINUE
   }
   public plugin_init(){
       register_plugin("Endround Stats","0.9","JustinHoMi")
       register_event("SendAudio","round_end","a","2=%!MRAD_terwin","2=%!
   MRAD_ctwin","2=%!MRAD_rounddraw")
       register_event("DeathMsg","deathmsg_event","a")
       return PLUGIN_CONTINUE
   }
