/* AMX Mod X
*   The Flop 10
*
*  ### by FaNa - www.FanasFarm.de ###
*  
*  v1.0: Initial release
*  v2.0: Fix for AMX X 1.60
*  v2.1: New damn cool looking MOTD window ;)
*
*  Plugin shows the worst 10 players when you type /flop10
*  in chat.
*
*
*  This file is part of AMX Mod X.
*
*
*  This program is free software; you can redistribute it and/or modify it
*  under the terms of the GNU General Public License as published by the
*  Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*  In addition, as a special exception, the author gives permission to
*  link the code of this program with the Half-Life Game Engine ("HL
*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
*  L.L.C ("Valve"). You must obey the GNU General Public License in all
*  respects for all of the code used other than the HL Engine and MODs
*  from Valve. If you modify this file, you may extend this exception
*  to your version of the file, but you are not obligated to do so. If
*  you do not wish to do so, delete this exception statement from your
*  version.
*/

/* do the includes ;) */
#include <amxmodx>
#include <amxmisc>
#include <csx>

/* just to be sure ... */
#define HTML_GUI 1

/* create the stuff we need ... */
new g_Buffer[2048], pos, stats[8], body[8], name[32], numbaa[4]

/* there we go ... */
getFlop10() {
  pos = copy(g_Buffer,2047,"<html><head><body><style type=text/css>")
  pos += copy(g_Buffer[pos],2047-pos,"body{font-family:Arial,sans-serif;font-size:12px;color:#FFCC99;background-color:#000000;margin-left:8px;margin-top:3px}.header{background-color:#9C0000;}.one{background-color:#310000;}.two{background-color:#630000;}")
  pos += copy(g_Buffer[pos],2047-pos,"</style></head><body><table width=100%><tr class=^"header^"><td>#</td><td>Nick</td><td>Kills</td><td>Deaths</td><td>Hits</td><td>Shots</td><td>HS</td></tr>")

  new imax = get_statsnum()
  new i=2
  
  for(new a = imax-1; a >= imax-10; --a){
    if (equal(numbaa,"one")) copy(numbaa,3,"two")
    else copy(numbaa,3,"one")
    get_stats(a,stats,body,name,31)
    pos += format(g_Buffer[pos],2047-pos,"<tr class=%s><td>%d.</td><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td></tr>",numbaa,a-imax+i,name,stats[0],stats[1],stats[5],stats[4],stats[2])
    i+=2
  }
  copy(g_Buffer[pos],2047-pos,"</table></body></html>")
}

/* what to be shown ... */
public cmdFlop10(id) {
  getFlop10()
  show_motd(id,g_Buffer,"Flop 10")
  return PLUGIN_CONTINUE
}

/* Plugin Info cheeeers :) */
public plugin_init() {
  register_plugin("The Flop 10","2.1","FaNa")
  register_clcmd("say /flop10","cmdFlop10",0,"- displays worst 10 players")
}
