/*
HP-PLUGIN 5.0 by Sir D.
 
Feature:
- Healthpoints und Armoranzeige Deines Gegners, nachdem er Dich gefraggt hat.
- Welche Waffe er benutzt hat.
- Wieviel Schaden Du ihm zugefügt hast.
- verschiedene Statistik-Anzeigen
- reagiert auf die Chateingaben "hp", "myhits", "hits" und "weapon".
 
 
NEU:
- Sprachauswahl zwischen Deutsch und Englisch mit dem Befehl hp_language 0/1 (0=englisch/1=deutsch);
- Distanzberechnung zwischen Gegner und Opfer in Meter.
 
 
Benötigt:
- HP- / und Statistik-Anzeigen werden nun ausschließlich per Menü angezeigt. Deswegen ist die Aktivierung von
  'amv_enable_beta "menu1"' in der adminmod.cfg zwingend erfordelich!
- installiertes LogD mit mp_logdetail 3 (logd_block 58 um die Injure-Logs abzublocken!)
- amv_enable_menu "menu1" in der adminmod.cfg
- plugin_sdal_allowsounds (optional). Wenn nicht installiert, kann der Client nicht '/stop' eingeben, um diese Anzeigen
  für sich zu deaktivieren.
 
- Durch das Plugin 'sdal_allowsounds' kann der Client per Chateingabe '/stop' bzw. '/play' entscheiden, ob er
  die Anzeigen sehen möchte. Generell werden sie ihm immer angezeigt, wenn er nicht einmal '/stop' eingegeben hat.
  Nähere Angaben dazu im Plugin sdal_allowsounds. 
 
Befehle:
NEU:
- hp_language 0/1   :0=englisch, 1=deutsch (default: deutsch)
- hp_distance 0/1	:schaltet die Anzeige über die Distanzangabe zwischen Opfer und Gegner aus/an	
ALT:
- hp_plugin 0/1		:schaltet das Plugin aus/an
- hp_dead 	0/1		:schaltet die Anzeige direkt nach dem Tod an/aus
- hp_armor 	0/1		:schaltet die Anzeige der Armor an/aus
- hp_weapon 0/1		:schaltet die Anzeige der Waffe an/aus
- hp_udid 	0/1		:schaltet die Anzeige der Schadenspunkte an/aus
 
vault.ini:
- HP_LANGUAGE 0=ENGLISH/1=GERMAN
- HP_DISTANCE 0/1
- HP_PLUGIN 0/1
- HP_DEAD 0/1
- HP_ARMOR 0/1
- HP_WEAPON 0/1
- HP_UDID 0/1
 
Änderungen zu Vorgängern:
--------------------------
5.0:- Auswahl der Sprache (englisch/deutsch)
	- Distanzberechnung zwischen 2 Spielern mit Umrechnung auf Meter.
    - Bugfix für die hp_settings Befehle, die nicht mehr funktionierten.
4.8:- Bugfix: Korrektes Löschen der Runden-Damage der Spieler
	- Bugfix: Ein neuer Spieler übernahm die Stats-Werte eines disconnecteten Spieler.
	- Änderung der Damage-Bewertung: 
	  Die verursachte Damage wird nun anhand der vorhandenen Spieler-HP berechnet
	  und nicht mehr an der Damage, die die Waffe insgesamt verursacht hat.
	  Beispiel: Wenn der gegnerische Spieler nur noch 17 HP hat, werden auch nur bei einem
	  Headshot diese 17 HP als Damage gutgeschrieben und nicht mehr der Wert,
	  der durch den Headshot mit dieser Waffe insgesamt hervorgerufen wurde.
4.7:- Statistik: Bester Spieler der Runde und Map, PvP-Statistik.
4.6:- Mit 'hp' kann man auch am Ende Runde das Statistik-Menü aufrufen.
	- Code-Veränderung der Waffen-Statistik
	- Headshot-Statistik
4.5: 	- Alles wird per Menü angezeigt. Darum kein Befehl für 'display' mehr nötig.
	- Mit 'myhits' ruft man seine eigene Schadens-Statistik auf.
	- Mit 'hits' ruft man die allg. Schadens-Statistik auf.
	- Mit 'weapon' ruft man die Waffen-Statistik auf.
	- Befehlsänderungen gegenüber den alten Versionen!
	- Änderung in neue Waffennamen und die neuen Waffen für CS 1.6 hinzugefügt.
	- Auf die Anzeige, wieviel Armor man dem Gegner abgezogen hat, wird verzichtet.
 
4.4: - Rechenfehler ausgemerzt. Danke an [FN] Rinde!
	- Wenn das Adminmod-Menü aktiviert ist, besteht die Möglichkeit mit der Chateingabe /hits den Spieler anzuzeigen,
  	  der den meisten Schaden an Spielern erzeugt hat.
	- Wenn das Adminmod-Menü aktiviert ist, besteht die Möglichkeit mit der Chateingabe /hitme alle Spieler anzuzeigen,
	  denen Du Schaden zugefügt hast. 
 
4.2/4.3:- Bugfixes
 
4.1:- Fix Waffennamen und Zeilenumbruch
	- neue Waffenerkennung
	- neue Vault.ini Werte
	- verbesserter Code
 
Vorraussetzung:
----------------------
Korrekt installiertes Logd, mp_logdetail 3 und vorhandene Logs. (log on)
Damit die Logs nicht zu groß werden, ist es ratsam, logd_block 58 ebenfalls
in die (listen)server.cfg einzutragen.
Zusätzlich wird amv_enable_beta "menu1" in der adminmod.cfg benötigt!!!!
 
Bei Problemen im www.adminmod.de Forum melden.
 
*/
 
#include <core> 
#include <console> 
#include <string> 
#include <admin> 
#include <adminlib>
#include <fixed>
 
new g_Version[] = "05.07.04_v5.0";
 
new Key[]="am_sound";
 
#define ACCESS_CONSOLE 131072
 
#define MAX_WEAPONS	26
/* Alte Waffennamen
new g_WeaponName[MAX_WEAPONS][MAX_NAME_LENGTH]	=	{{"usp"},{"glock18"},{"deagle"},{"mp5navy"},{"m4a1"},{"ak47"},{"awp"},{"aug"},{"sg552"},
							{"scout"},{"m249"},{"p90"},{"p228"},{"tmp"},{"mac10"},{"ump40"},{"fiveseven"},
							{"elite"},{"m3"},{"xm1014"},{"sg550"},{"g3sg1"},{"grenade"},{"knife"}};
 
new g_WeaponText[MAX_WEAPONS][MAX_TEXT_LENGTH]	=	{{"der H&K USP"},{"der Glock 18"},{"der Desert Eagle"},
							{"der MP5 Navy"},{"der M4A1"},{"der AK-47"},
							{"der AWP"},{"der Steyr Aug"},{"der Sig SG-552"},{"der Steyr Scout"},{"der FN M249 Para"},
							{"der FN P90"},{"der SIG P228"},{"der Steyr TMP"},{"der Ingram MAC-10"},
							{"der H&K UMP45"},{"der FN Five-Seven"},{"den Elite Dual Berettas"},
							{"der M3 Super90"},{"der XM1014"},{"der Sig SG-550 Sniper"},{"der H&K G3/SG-1"},
							{"der HE Granate"},{"dem Messer"}};
*/
 
new g_WeaponName[MAX_WEAPONS][]= {
    "glock18",
    "usp",
    "p228",
    "deagle",
    "elite",
    "fiveseven",
    "m3",
    "xm1014",
    "mac10",
    "mp5navy",
    "ump45",
    "p90",
    "tmp",
    "galil",
    "ak47",
    "scout",
    "sg552",
    "awp",
    "g3sg1",
    "famas",
    "aug",
    "m4a1",
    "sg550",
    "m249",
    "grenade",
    "knife"
};
 
new g_WeaponText[MAX_WEAPONS][]= {
    "9x19mm Sidearm",
    "K&M .45 Tactical",
    "228 Compact",
    "Night Hawk .50C",
    ".40 Dual Elites",
    "ES Five-Seven",
    "Leone 12 Gauge Super",
    "Leone YG1265 Auto Shotgun",
    "Ingram MAC-10",
    "K&M Sub-Machine Gun",
    "K&M UMP45",
    "ES C90",
    "Schmidt Machine Pistol",
    "IDF Defender",
    "CV-47",
    "Schmidt Scout",
    "Krieg 552 Commando",
    "Magnum Sniper Rifle",
    "D3/AU-1 Semi-Auto Sniper Rifle",
    "Clarion 5.56",
    "Bullpup",
    "Maverick M4A1 Carabine",
    "Krieg 550 Commando",
    "ES M249 Para",
    "HE Grenade",
    "Knife"
};
 
/*Ausgetestete Damage-Werte der Waffen. Ausgehend vom maximaler Bodydamage. 
Jeder höhere Damage-Wert muss also ein Headshot sein. Werte sind aufgerundet, um wirklich sicher zu sein, 
dass es sich um einen Headshot handelt. Naja, sind eben Annäherungswerte.*/
/*Pistolen*/
#define DEAGLE		80
#define GLOCK		40
#define USP			40
#define ELITE		40
#define FIVESEVEN	40
#define P228		40
/*Shotguns, unmöglich mit Annäherung genau den Headshot zu definieren.*/
#define M3			200
#define XM1014		200
/*SMG*/
#define MP5			36
#define P90			40
#define TMP			36
#define MAC			40
#define UMP40		45
/*Rifles*/
#define GALLIL		45
#define DEFENDER	45
#define AUG			50
#define SG552		50
#define AWP			155
#define M4A1		50
#define AK47		50
#define SCOUT		95
#define SG550		70
#define G3SG1		70
/*MG*/
#define M249		50
#define HEGREN		100
#define KNIFE		100
 
 
new g_WeaponDamage[MAX_WEAPONS][MAX_NUMBER_LENGTH]= 	{{GLOCK},{USP},{P228},{DEAGLE},{ELITE},{FIVESEVEN},
							{M3},{XM1014},{MAC},{MP5},{UMP40},{P90},{TMP},{GALLIL},
							{AK47},{SCOUT},{SG552},{AWP},{G3SG1},{DEFENDER},{AUG},{M4A1},
							{SG550},{M249},{HEGREN},{KNIFE}};
 
new g_PlayerEnemy[MAX_PLAYERS][MAX_NAME_LENGTH];
new g_PlayerEnemyID[MAX_PLAYERS];
new g_PlayerEnemyHP[MAX_PLAYERS];
new g_PlayerEnemyArmor[MAX_PLAYERS];
new g_PlayerEnemyWeapon[MAX_PLAYERS];
new fixed:g_PlayerEnemyDistance[MAX_PLAYERS];
new g_PlayerEnemyInjure[MAX_PLAYERS][MAX_PLAYERS];
new g_PlayerEnemyInjureTotal[MAX_PLAYERS][MAX_PLAYERS];
new g_PlayerHS[MAX_PLAYERS];
new g_PlayerHSMaxID;
new g_KillsByWeapon[MAX_WEAPONS];
new g_KillsMaxWeaponID;
new g_TotalKills;
new g_BestPlayerRound[MAX_PLAYERS];
new g_BestPlayerRoundID;
new g_BestPlayerMap[MAX_PLAYERS];
new g_BestPlayerMapID;
new g_PvPKill[MAX_PLAYERS][MAX_PLAYERS];
 
new g_round_end;
 
new g_language=1;
new g_plugin=1;
new g_display_after_dead=1;
new g_display_armor=1;
new g_display_weapon=1;
new g_display_udid=1;
new g_display_distance=1;
 
new g_UserMenu[MAX_PLAYERS];
new g_UserSelectMenu[MAX_PLAYERS];
new g_UserMenuTime[MAX_PLAYERS];
 
forward allowsound(User[]);
forward display_victim(User[],UserID);
forward reset_array(UserID);
forward most_damage(User[],UserID);
forward more_statistic(User[],UserID);
forward most_used_weapon(User[],UserID);
 
 
public plugin_init(){
	new Menu[MAX_NAME_LENGTH];
	getstrvar("amv_enable_beta",Menu,MAX_NAME_LENGTH);
	if(strstrx(Menu,"menu1")==-1){
		plugin_registerinfo("HP Plugin","Disabled!^nMissing 'amv_enable_beta menu1' in adminmod.cfg",g_Version);
	}else{
		plugin_registerinfo("HP Plugin","Announces hp, armor and weapon of your enemy and the damage you did to him",g_Version);
		plugin_registercmd("hp","hp_setting",ACCESS_MAP,"hp: show plugin settings");
		plugin_registercmd("hp_plugin","hp_setting",ACCESS_MAP,"hp_plugin '0/1': Turns plugin off/on");
		plugin_registercmd("hp_dead","hp_setting",ACCESS_MAP,"hp_dead '0/1': Turns hp display after dead off/on");
		plugin_registercmd("hp_armor","hp_setting",ACCESS_MAP,"hp_armor '0/1': Turns armor display off/on");
		plugin_registercmd("hp_weapon","hp_setting",ACCESS_MAP,"hp_weapon '0/1': Turns weapon display off/on");
		plugin_registercmd("hp_udid","hp_setting",ACCESS_MAP,"hp_udid '0/1': Turns damage display off/on (Damage u did to your enemy)");
		plugin_registercmd("hp_language","hp_setting",ACCESS_MAP,"hp_language '0/1': Selects language (0=english/1=german)");
		plugin_registercmd("hp_distance","hp_setting",ACCESS_MAP,"hp_distance '0/1': Turns distance display on/off between victim and attacker.");
 
		plugin_registercmd("hp_kill","hp_kill",ACCESS_CONSOLE);
		plugin_registercmd("hp_injure","hp_injure",ACCESS_CONSOLE);
		plugin_registercmd("hp_reset","hp_reset",ACCESS_CONSOLE);
		plugin_registercmd("say","HandleSay",ACCESS_ALL,"say hp/hp?/?hp: hp of your enemy who kills u");
		plugin_registercmd("menuselect","HandleMenu",ACCESS_ALL);
		plugin_registercmd("radio1","SetMenuData",ACCESS_ALL);
		plugin_registercmd("radio2","SetMenuData",ACCESS_ALL);
		plugin_registercmd("radio3","SetMenuData",ACCESS_ALL);
		plugin_registercmd("buyequip","SetMenuData",ACCESS_ALL);
		plugin_registercmd("buy","SetMenuData",ACCESS_ALL);
		plugin_registercmd("chooseteam","SetMenuData",ACCESS_ALL);
		plugin_registercmd("showbriefing","SetMenuData",ACCESS_ALL);
 
		exec( "logd_reg 57 admin_command hp_kill" );
		exec( "logd_reg 58 admin_command hp_injure" ); 
		exec( "logd_reg 62 admin_command hp_reset" );  
 
		get_vaultnumdata("HP_LANGUAGE",g_language);
		if(g_language==0){
			selfmessage("[HP] Messages in game are shown in english!");
		}else{
			selfmessage("[HP] Messages in game are shown in german!");
		}
		get_vaultnumdata("HP_PLUGIN",g_plugin);
		if(g_plugin==0){
			selfmessage("[HP] Plugin is disabled!");
		}			
		get_vaultnumdata("HP_DEAD",g_display_after_dead);
		if(g_display_after_dead==0){
			selfmessage("[HP] Automatic display of attacker's health to victim is disabled!");
		}
		get_vaultnumdata("HP_ARMOR",g_display_armor);
		if(g_display_armor==0){
			selfmessage("[HP] Display of attacker's armor is disabled!");
		}
		get_vaultnumdata("HP_WEAPON", g_display_weapon);
		if(g_display_weapon==0){
			selfmessage("[HP] Display of attacker's weapon is disabled!");
		}
		get_vaultnumdata("HP_UDID",g_display_udid);
		if(g_display_udid==0){
			selfmessage("[HP] Display of damage Victim did to his enemy is disabled!");
		}
 
		get_vaultnumdata("HP_DISTANCE",g_display_distance);
		if(g_display_distance==0){
			selfmessage("[HP] Display of distance between attacker and victim is disabled!");
		}
	}	
	return PLUGIN_CONTINUE;
}
 
public hp_setting(HLCommand,HLData,HLUserName,UserIndex){
	new Data[MAX_DATA_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new Command[MAX_COMMAND_LENGTH];
	new i;
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
 
	if(strlen(Data)!=0){
		i=strtonum(Data);
		if(i>1 || i<0){
			i=1;
		}
		if(strcmp(Command[3],"plugin")==0){
			set_vaultnumdata("HP_PLUGIN",i);
			g_plugin=i;
		}else if(strcmp(Command[3],"dead")==0){
			set_vaultnumdata("HP_DEAD",i);
			g_display_after_dead=i;
		}else if(strcmp(Command[3],"armor")==0){
			set_vaultnumdata("HP_ARMOR",i);
			g_display_armor=i;
		}else if(strcmp(Command[3],"weapon")==0){
			set_vaultnumdata("HP_WEAPON",i);
			g_display_weapon=i;
		}else if(strcmp(Command[3],"udid")==0){
			set_vaultnumdata("HP_UDID",i);
			g_display_udid=i;
		}else if(strcmp(Command[3],"language")==0){
			set_vaultnumdata("HP_LANGUAGE",i);
			g_language=i;
		}else if(strcmp(Command[3],"distance")==0){
			set_vaultnumdata("HP_DISTANCE",i);
			g_display_distance=i;
		}
	}
	selfmessage("");
	snprintf(Text,MAX_TEXT_LENGTH,"HP-PLUGIN (v.%s):",g_Version);
	selfmessage(Text);
	selfmessage("-----------------------------");
	selfmessage("* COMMANDS:");
	selfmessage("* hp_language 0/1: set the language (0=english, 1=german (default: german)");
	selfmessage("* hp_plugin 0/1: turns plugin on/off");
	selfmessage("* hp_dead 	0/1: 1=displays menu messages directly after death");
	selfmessage("* hp_armor 0/1: 1=displays the armor damage");
	selfmessage("* hp_weapon 0/1: 1=displays which weapon was used");
	selfmessage("* hp_udid 	0/1: 1=displays how much damage you did to your opponent");
	selfmessage("* hp_distance 	0/1: 1=displays the distance between attacker and victim in meters.");
	selfmessage("-----------------------------");
	selfmessage("* CURRENT SETTINGS: (0=deactivated; 1=activated)");
	snprintf(Text,MAX_TEXT_LENGTH,"* Plugin is set to %i",g_plugin);
	selfmessage(Text);
	snprintf(Text,MAX_TEXT_LENGTH,"* Messages in game are set to %i (0=english/1=german)",g_language);
	selfmessage(Text);	
	snprintf(Text,MAX_TEXT_LENGTH,"* Display hp after dead is set to %i",g_display_after_dead);
	selfmessage(Text);
	snprintf(Text,MAX_TEXT_LENGTH,"* Display armor is set to %i",g_display_armor);
	selfmessage(Text);
	snprintf(Text,MAX_TEXT_LENGTH,"* Display weapon is set to %i",g_display_weapon);
	selfmessage(Text);
	snprintf(Text,MAX_TEXT_LENGTH,"* Display damage you did to your enemy is set to %i",g_display_udid);
	selfmessage(Text);
	snprintf(Text,MAX_TEXT_LENGTH,"* Display distance between attacker and victim is set to %i.",g_display_distance);
	selfmessage(Text);
	selfmessage("-----------------------------");
	selfmessage("");
	return PLUGIN_HANDLED;
}
 
allowsound(User[]){
	new Info[MAX_NUMBER_LENGTH];
	new iInfo;
	new Authid[MAX_AUTHID_LENGTH];
	get_userAuthID(User,Authid,MAX_AUTHID_LENGTH);
	if(strcmp(Authid,"BOT")!=0){
		get_userinfo(User,Key,Info,MAX_NUMBER_LENGTH);
		iInfo=strtonum(Info);
		if(strlen(Info)==0 || iInfo > 0){/*damit wird automatisch immer der Sound auf 1 gesetzt,wenn kein setinfo vorhanden, bis 'stop' eingegeben wird*/
			return 1;
		}
	}
	return 0;
}
 
public hp_kill(HLCommand,HLData,HLUserName,UserIndex){
	new Data[MAX_DATA_LENGTH];
	new Victim[MAX_NAME_LENGTH];
	new Weapon[MAX_NAME_LENGTH];
	new Attacker[MAX_NAME_LENGTH];
	new strAID[3];
	new strVID[3];
	new iAHealth;
	new iAArmor;
	new iAID;
	new iVID;
	new iATeam;
	new iVTeam;
	new i;
 
	convert_string(HLData,Data,MAX_DATA_LENGTH);
 
	strsplit(Data," ",strAID,3,strVID,3,Weapon,MAX_NAME_LENGTH);
 
	iAID=strtonum(strAID);
	iVID=strtonum(strVID);
 
	playerinfo(iAID,Attacker,MAX_NAME_LENGTH,_,_,iATeam);
	playerinfo(iVID,Victim,MAX_NAME_LENGTH,_,_,iVTeam);
 
	get_userHealth(Attacker, iAHealth);
	get_userArmor(Attacker, iAArmor);
 
	get_user_distance(Attacker,Victim,iVID);
 
	strcpy(g_PlayerEnemy[iVID][0],Attacker,MAX_NAME_LENGTH);
	g_PlayerEnemyHP[iVID]=iAHealth;
	g_PlayerEnemyArmor[iVID]=iAArmor;
	g_PlayerEnemyID[iVID]=iAID;
	g_TotalKills++;
	g_PvPKill[iAID][iVID] +=1;
	if(iATeam!=iVTeam){
		g_BestPlayerRound[iAID] +=1;
	}else{
		g_BestPlayerRound[iAID] -=1;
	}
	if(g_BestPlayerRound[g_BestPlayerRoundID]<g_BestPlayerRound[iAID]){
		g_BestPlayerRoundID=iAID;
	}
	for(i=0;i<MAX_WEAPONS;i++){
		if(strcmp(Weapon,g_WeaponName[i])==0){
			g_PlayerEnemyWeapon[iVID]=i;
			g_KillsByWeapon[i] += 1;
			if(g_KillsByWeapon[g_KillsMaxWeaponID]<g_KillsByWeapon[i]){
				g_KillsMaxWeaponID=i;
			}
			break;
		}
	}
 
	if(g_display_after_dead && allowsound(Victim)){
		display_victim(Victim,iVID);
	}
	return PLUGIN_CONTINUE;
}
 
get_user_distance(Attacker[],Victim[],iVID){
	new ax;
	new ay;
	new az;
	new vx;
	new vy;
	new vz;
	get_userorigin(Attacker,ax,ay,az);
	get_userorigin(Victim,vx,vy,vz);
	g_PlayerEnemyDistance[iVID]= distance(ax,vx,ay,vy,az,vz);
}
 
 
//Calculating Distance (Code of math.inc written by [WING] Black Knight)
stock fixed:distance(x1,x2,y1=0,y2=0,z1=0,z2=0){ 
	new fixed:fNumStart=-1.000;
	new fixed:fSum=0.000;
	new iDx,iDy,iDz;
	new iError=0;
 
	iDx=(x1-x2)*(x1-x2);
	iDy=(y1-y2)*(y1-y2);
	iDz=(z1-z2)*(z1-z2);
 
	fNumStart=fixed(max(max(iDx,iDy),iDz));
	fSum=fixed(iDx+iDy+iDz);
	if(fSum==0.000){
		return 0.000;
	}
	fSum=fmul(f_sqrt(fSum,iError,fNumStart),0.025);
	return fSum;
}
 
stock fixed:f_abs(fixed:fNum) { 
	if(fNum >= 0.000) { 
		return fNum; 
	}
	return fmul(fNum,-1.000); 
}
 
stock fixed:f_sqrt(fixed:fNum,&iError=0,fixed:fNumStart=1.000) { 
	new fixed:fNum2=fNum;
	new fixed:fOne=1.000;
 
	if(f_abs(fNum)!=fNum){
		iError=1;		
		return -1.000;
	}
 
	if(fNumStart==fNum2){
		fNumStart=1.000;
	}
 
	if(fNum<1.000){
		fNum2=fdiv(fOne,fNum);
	}
 
	for(new i=0;i<100;i++){
		fNum2=fdiv(fNum2+fNumStart,2.000); 
		fNumStart=fdiv(fNum,fNum2);
		if(fNum2 <= fNumStart){
			break;
		}
	}
 
	return fNum2; 
}
 
stock fixtostr(fixed:fNumber,sNumber[],iMaxLength){
	new iNumber,iFrac;
	new iSign=1;
	new sFrac[4];
 
	if(fNumber<0.000){
		iNumber=fround(fNumber,fround_ceil);
	}
	else{
		iNumber=fround(fNumber,fround_floor);
	}
	iFrac=ffract(fNumber);
	if(iFrac<0){
		iFrac*=-1;
		iSign=-1;
	}
	numtostr(iFrac,sFrac);
	switch(strlen(sFrac)){
		case 2:
			snprintf(sNumber,iMaxLength,"%d.0%s",iNumber,sFrac);
		case 1:
			snprintf(sNumber,iMaxLength,"%d.00%s",iNumber,sFrac);
		default:
			snprintf(sNumber,iMaxLength,"%d.%s",iNumber,sFrac);
	}
	if(iSign==-1 && iNumber==0){
		snprintf(sNumber,iMaxLength,"-%s",sNumber);
	}
	return PLUGIN_CONTINUE;
}
 
public hp_injure(HLCommand,HLData,HLUserName,UserIndex){
	new Data[MAX_DATA_LENGTH];
	new Dummy[MAX_DATA_LENGTH];
	new strAID[3];
	new strVID[3];
	new sWeapon[MAX_NAME_LENGTH];
	new sHealth[4];
	new sDamage[4];
	new iVID;
	new iAID;
	new iDamage;
	new iHealth;
	new i;
 
	convert_string(HLData,Data,MAX_DATA_LENGTH);
 
	strsep(Data," ",strAID,3,strVID,3,sWeapon,MAX_NAME_LENGTH,Dummy,MAX_DATA_LENGTH);
	strsplit(Dummy,"#",sDamage,4,sDamage,4,sHealth,4,sHealth,4);
 
	iAID=strtonum(strAID);
	iVID=strtonum(strVID);
	iDamage=strtonum(sDamage);
	iHealth=strtonum(sHealth);
 
	if(iHealth<0){
		iDamage=iDamage+iHealth;
	}
	g_PlayerEnemyInjure[iAID][iVID]+=iDamage;
	g_PlayerEnemyInjure[iAID][0]+=iDamage;
	g_PlayerEnemyInjureTotal[iAID][0]+=iDamage;
 
	for(i=0;i<MAX_WEAPONS;i++){
		if(strcmp(sWeapon,g_WeaponName[i])==0 && iDamage >= g_WeaponDamage[i][0]){
			g_PlayerHS[iAID]+=1;
			if(g_PlayerHS[iAID]>g_PlayerHS[g_PlayerHSMaxID]){
				g_PlayerHSMaxID=iAID;
			}
		}
	}
	return PLUGIN_CONTINUE;
}
 
public hp_reset(HLCommand,HLData,HLUserName,UserIndex){
	new Data[MAX_NAME_LENGTH];
	new i;
	new j;
	new maxplayers=maxplayercount();
   	convert_string(HLData,Data,MAX_NAME_LENGTH); 
    	if(Data[0]=='G' || Data[8]=='R'){
		g_TotalKills=0;
		g_KillsMaxWeaponID=0;
		g_PlayerHSMaxID=0;
		g_BestPlayerMapID=0;
    		for(i=0;i<=maxplayers;i++){
    			g_PlayerEnemyInjureTotal[i][0]=0;
    			g_PlayerHS[i]=0;
    			g_BestPlayerMap[i]=0;
    			for(j=0;j<=maxplayers;j++){
    				g_PvPKill[i][j]=0;
    			}
    		}
    		for(i=0;i<=MAX_WEAPONS;i++){
    			g_KillsByWeapon[i]=0;
    		}			
    	}else if(Data[6]=='S'){
    		g_round_end=0;
    		g_BestPlayerRoundID=0;
		for(i=0;i<=maxplayers;i++){
			strinit(g_PlayerEnemy[i]);
			strinit(g_PlayerEnemyInjure[i]);
			g_PlayerEnemyID[i]=0;
			g_PlayerEnemyHP[i]=0;
			g_PlayerEnemyArmor[i]=0;
			g_PlayerEnemyWeapon[i]=0;
			g_UserMenu[i]=0;
			g_UserSelectMenu[i]=0;
			g_UserMenuTime[i]=0;
			g_BestPlayerRound[i]=0;
			for(j=0;j<=maxplayers;j++){
				strinit(g_PlayerEnemy[i][j]);
				strinit(g_PlayerEnemyInjure[i][j]);
			}
		}
	}else if(Data[6]=='E'){
		g_round_end=1;
	}
	return PLUGIN_CONTINUE;
}	
 
public HandleSay(HLCommand,HLData,HLUserName,UserIndex){
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new IsDead;
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	if (strcasestrx(Data, "hp")!=-1 || strcasestrx(Data, "myhits")!=-1 || strcasestrx(Data, "hits")!=-1 || strcasestrx(Data, "weapon")!=-1){
		if(g_plugin){
			if(playerinfo(UserIndex,User,MAX_NAME_LENGTH,_,_,_,IsDead)){
				if (strcasestrx(Data, "hp")!=-1){
					if(g_PlayerEnemyID[UserIndex]!=0 && IsDead == 1){
						display_victim(User,UserIndex);
					}else{
						display_statistik(User,UserIndex);
					}
				}else if (strcasestrx(Data, "myhits")!=-1){
					own_statistic(User,UserIndex);
				}else if (strcasestrx(Data, "hits")!=-1){
					most_damage(User,UserIndex);
				}else if (strcasestrx(Data, "weapon")!=-1){
					most_used_weapon(User,UserIndex);
				}
			}
		}
	}
	return PLUGIN_CONTINUE;
}
 
display_victim(User[],UserID){
	new Text[512];
	new Armor[MAX_TEXT_LENGTH];
	new Weapon[MAX_TEXT_LENGTH];
	new UDid[MAX_TEXT_LENGTH];
	new Distance[MAX_TEXT_LENGTH];
	if(g_display_armor){
		if(g_language){
			snprintf(Armor,MAX_TEXT_LENGTH,"und %i Armor.",g_PlayerEnemyArmor[UserID]);
		}else{
			snprintf(Armor,MAX_TEXT_LENGTH,"and %i armor.",g_PlayerEnemyArmor[UserID]);
		}
	}
	if(g_display_weapon){
		if(g_language){
			snprintf(Weapon,MAX_TEXT_LENGTH,"^nEr traf Dich mit der Waffe: ^"%s^"!",g_WeaponText[g_PlayerEnemyWeapon[UserID]]);
		}else{
			snprintf(Weapon,MAX_TEXT_LENGTH,"^nHe killed you with %s!",g_WeaponText[g_PlayerEnemyWeapon[UserID]]);
		}
	}
	if(g_display_udid){
		if(g_language){
			snprintf(UDid,MAX_TEXT_LENGTH,"^nDu hast ihm %i HP Schaden zugefuegt!",g_PlayerEnemyInjure[UserID][g_PlayerEnemyID[UserID]]);
		}else{
			snprintf(UDid,MAX_TEXT_LENGTH,"^nYou did %i HP damage to him!",g_PlayerEnemyInjure[UserID][g_PlayerEnemyID[UserID]]);
		}		
	}
	if(g_display_distance){
		new Meters[MAX_NUMBER_LENGTH];
		fixtostr(fixed:g_PlayerEnemyDistance[UserID],Meters,MAX_NUMBER_LENGTH);
		if(g_language){
			snprintf(Distance,MAX_TEXT_LENGTH,"^nEr war %s m von Dir entfernt!",Meters);
		}else{
			snprintf(Distance,MAX_TEXT_LENGTH,"^nHe killed you from distance of %s m!",Meters);
		}
	}
 
	if(g_language){
		snprintf(Text,MAX_TEXT_LENGTH,"\r%s^n^n\what noch %i HP %s%s%s%s^n^n^n\y1. Weiter -- 0. Cancel",g_PlayerEnemy[UserID],g_PlayerEnemyHP[UserID],Armor,Weapon,UDid,Distance);
	}else{
		snprintf(Text,MAX_TEXT_LENGTH,"\r%s^n^n\wstill has %i HP %s%s%s%s^n^n^n\y1. Next -- 0. Cancel",g_PlayerEnemy[UserID],g_PlayerEnemyHP[UserID],Armor,Weapon,UDid,Distance);
	}
	g_UserMenu[UserID]=1;
	g_UserMenuTime[UserID]=systemtime();
	menu(User,Text,1023,10);
}
 
display_statistik(User[],UserID){
	new Text[512];
	new IsDead;
	new a;
	snprintf(Text,512,"\yHP-STATISTIC:^n");
	playerinfo(UserID,User,MAX_NAME_LENGTH,_,_,_,IsDead);
	if(IsDead || g_round_end){
		if(g_language){
			snprintf(Text,512,"%s^n\w1. Eigene Damage",Text);
		}else{
			snprintf(Text,512,"%s^n\w1. Own damagereport",Text);
		}
		a=1;
	}
	if(g_language){
		snprintf(Text,512,"%s^n\w2. allg. Damage^n3. Waffen^n4. Headshots^n5. Rundenpunkte^n6. Mappunkte^n7. PvP-Statistik",Text);
	}else{
		snprintf(Text,512,"%s^n\w2. Total Damage^n3. Weapons^n4. Headshots^n5. Roundscore^n6. Mapscore^n7. PvP-Statistic",Text);
	}
	a=a+126;
	if(g_PlayerEnemyID[UserID]!=0 && IsDead){
		if(g_language){
			strcat(Text,"^n9. HP Deines Gegners",MAX_TEXT_LENGTH);
		}else{
			strcat(Text,"^n9. HP of your opponent",MAX_TEXT_LENGTH);
		}
		a=a+256;
	}
	strcat(Text,"^n^n\y0. Cancel",MAX_TEXT_LENGTH);
	a=a+512;
	g_UserMenu[UserID]=2;
	g_UserMenuTime[UserID]=systemtime();
	menu(User,Text,a,10);
}
 
own_statistic(User[],UserID){
	new Text[512];
	new Enemy[MAX_NAME_LENGTH];
	new i;
	new j;
	new x;
	new maxplayers=maxplayercount();
	new maxdam;
 
	for(i=1;i<=maxplayers;i++){
		if(g_PlayerEnemyInjure[UserID][i]!=0){
			if(g_PlayerEnemyInjure[UserID][i]>maxdam){
				maxdam=g_PlayerEnemyInjure[UserID][i];
			}
		}
	}
	if(g_language){
		snprintf(Text,MAX_TEXT_LENGTH,"\ySchadens-Statistik von %s:^n",User);
	}else{
		snprintf(Text,MAX_TEXT_LENGTH,"\yDamage-Report of %s:^n",User);
	}
	for(i=maxdam;i>0;i--){
		if(x==5){
			break;
		}
		for(j=1;j<=maxplayers;j++){
			if(x==5){
				break;
			}
			if(g_PlayerEnemyInjure[UserID][j]!=0){
				if(g_PlayerEnemyInjure[UserID][j]==i){
					if(playerinfo(j,Enemy,MAX_NAME_LENGTH)){
						x++;
						snprintf(Text,MAX_TEXT_LENGTH,"%s^n\w%i -- %s",Text,g_PlayerEnemyInjure[UserID][j],Enemy);
					}
				}
			}
		}	
	}
	strcat(Text,"^n^n\y1. Back",MAX_TEXT_LENGTH);
	g_UserMenu[UserID]=3;
	g_UserMenuTime[UserID]=systemtime();
	menu(User,Text,1023,10);
}
 
most_damage(User[],UserID){
	new Text[512];
	new maxplayers=maxplayercount();
	new Name[MAX_NAME_LENGTH];
	new Name2[MAX_NAME_LENGTH];
	new i;
	new round_dam_playeruid;
	new round_damage;
	new map_dam_playeruid;
	new map_damage;
	if(g_language){
		snprintf(Text,512,"\yDie hoechste Damage verursachte:");
	}else{
		snprintf(Text,512,"\yMost disruptive player:");
	}
	for(i=1;i<=maxplayers;i++){
		if(g_PlayerEnemyInjure[i][0]!=0){
			if(g_PlayerEnemyInjure[i][0]>round_damage){
				round_damage=g_PlayerEnemyInjure[i][0];
				round_dam_playeruid=i;
			}
		}
	}
 
	for(i=1;i<=maxplayers;i++){
		if(g_PlayerEnemyInjureTotal[i][0]!=0){
			if(g_PlayerEnemyInjureTotal[i][0]>map_damage){
				map_damage=g_PlayerEnemyInjureTotal[i][0];
				map_dam_playeruid=i;
			}
		}
	}
 
	if(round_dam_playeruid!=0){
		playerinfo(round_dam_playeruid,Name,MAX_NAME_LENGTH);
		if(g_language){
			snprintf(Text,512,"%s^n^nIn dieser Runde:^n^n\w%s mit %i HP",Text,Name,round_damage);
		}else{
			snprintf(Text,512,"%s^n^nin this round:^n^n\w%s with %i HP",Text,Name,round_damage);
		}
	}
	if(map_dam_playeruid!=0){
		playerinfo(map_dam_playeruid,Name2,MAX_NAME_LENGTH);
		if(g_language){
			snprintf(Text,512,"%s^n^n\yInnerhalb der Mapzeit:^n^n\w%s mit %i HP",Text,Name2,map_damage);
		}else{
			snprintf(Text,512,"%s^n^n\yduring maptime:^n^n\w%s with %i HP",Text,Name2,map_damage);
		}			
	}
	strcat(Text,"^n^n\y1. Back",MAX_TEXT_LENGTH);
	g_UserMenu[UserID]=4;
	g_UserMenuTime[UserID]=systemtime();
	menu(User,Text,1023,10);
}
 
most_used_weapon(User[],UserID){
	new Text[512];
	new i;
	new j;
	new x;
	if(g_language){
		snprintf(Text,MAX_TEXT_LENGTH,"\yMeist benutzte Waffen:^n");
	}else{
		snprintf(Text,MAX_TEXT_LENGTH,"\yMost weapons used:^n");
	}
	for(i=g_KillsByWeapon[g_KillsMaxWeaponID];i>0;i--){
		if(x==5){
			break;
		}
		for(j=0;j<MAX_WEAPONS;j++){
			if(x==5){
				break;
			}
			if(g_KillsByWeapon[j]!=0){
				if(g_KillsByWeapon[j]==i){
					x++;
					snprintf(Text,MAX_TEXT_LENGTH,"%s^n\w%i -- %s",Text,g_KillsByWeapon[j],g_WeaponText[j]);
				}
			}
		}	
	}
	strcat(Text,"^n^n\y1. Back",MAX_TEXT_LENGTH);
	g_UserMenu[UserID]=5;
	g_UserMenuTime[UserID]=systemtime();
	menu(User,Text,1023,10);
}
 
most_headshots(User[],UserID){
	new Text[512];
	new maxplayers=maxplayercount();
	new Player[MAX_NAME_LENGTH];
	new i;
	new j;
	new x;
	if(g_language){
		snprintf(Text,MAX_TEXT_LENGTH,"\ySpieler mit den meisten Headshots:^n");
	}else{
		snprintf(Text,MAX_TEXT_LENGTH,"\yPlayers with most headshots:^n");
	}
	for(i=g_PlayerHS[g_PlayerHSMaxID];i>0;i--){
		if(x==5){
			break;
		}
		for(j=1;j<=maxplayers;j++){
			if(x==5){
				break;
			}
			if(g_PlayerHS[j]!=0){
				if(g_PlayerHS[j]==i){
					x++;
					playerinfo(j,Player,MAX_NAME_LENGTH);
					snprintf(Text,MAX_TEXT_LENGTH,"%s^n\w%i -- %s",Text,g_PlayerHS[j],Player);
				}
			}
		}	
	}
	strcat(Text,"^n^n\y1. Back",MAX_TEXT_LENGTH);
	g_UserMenu[UserID]=4;
	g_UserMenuTime[UserID]=systemtime();
	menu(User,Text,1023,10);
}
 
best_playerround(User[],UserID){
	new Text[512];
	new maxplayers=maxplayercount();
	new Player[MAX_NAME_LENGTH];
	new i;
	new j;
	new x;
	if(g_language){
		snprintf(Text,MAX_TEXT_LENGTH,"\yDie besten Spieler der Runde:^n");
	}else{
		snprintf(Text,MAX_TEXT_LENGTH,"\yBest players of the round:^n");
	}
	for(i=g_BestPlayerRound[g_BestPlayerRoundID];i>0;i--){
		if(x==5){
			break;
		}
		for(j=1;j<=maxplayers;j++){
			if(x==5){
				break;
			}
			if(g_BestPlayerRound[j]!=0){
				if(g_BestPlayerRound[j]==i){
					x++;
					playerinfo(j,Player,MAX_NAME_LENGTH);
					snprintf(Text,MAX_TEXT_LENGTH,"%s^n\w%i -- %s",Text,g_BestPlayerRound[j],Player);
				}
			}
		}	
	}
	strcat(Text,"^n^n\y1. Back",MAX_TEXT_LENGTH);
	g_UserMenu[UserID]=5;
	g_UserMenuTime[UserID]=systemtime();
	menu(User,Text,1023,10);
}
 
best_playermap(User[],UserID){
	new Text[512];
	new maxplayers=maxplayercount();
	new Player[MAX_NAME_LENGTH];
	new PlayerPoints[MAX_PLAYERS];
	new mostfrags;
	new i;
	new j;
	new x;
	if(g_language){
		snprintf(Text,MAX_TEXT_LENGTH,"\yDie besten Spieler der Map:^n");
	}else{
		snprintf(Text,MAX_TEXT_LENGTH,"\yBest players of the map:^n");
	}
	for(j=1;j<=maxplayers;j++){
		if(playerinfo(j,Player,MAX_NAME_LENGTH)){
			get_userFrags(Player,PlayerPoints[j]);
			if(PlayerPoints[j]>mostfrags){
				mostfrags=PlayerPoints[j];
			}
		}
	}
 
	for(i=mostfrags;i>0;i--){
		if(x==5){
			break;
		}
		for(j=1;j<=maxplayers;j++){
			if(x==5){
				break;
			}
			if(PlayerPoints[j]!=0){
				if(PlayerPoints[j]==i){
					x++;
					if(playerinfo(j,Player,MAX_NAME_LENGTH)){
						snprintf(Text,MAX_TEXT_LENGTH,"%s^n\w%i -- %s",Text,PlayerPoints[j],Player);
					}
				}
			}
		}	
	}
	strcat(Text,"^n^n\y1. Back",MAX_TEXT_LENGTH);
	g_UserMenu[UserID]=6;
	g_UserMenuTime[UserID]=systemtime();
	menu(User,Text,1023,10);
}
 
pvp_statistic(User[],UserID){
	new Text[512];
	new maxplayers=maxplayercount();
	new Player[MAX_NAME_LENGTH];
	new j;
	if(g_language){
		snprintf(Text,MAX_TEXT_LENGTH,"\y%s gegen:^n",User);
	}else{
		snprintf(Text,MAX_TEXT_LENGTH,"\y%s versus:^n",User);
	}
	for(j=1;j<=maxplayers;j++){
		if(g_PvPKill[UserID][j]!=0 || g_PvPKill[j][UserID]!=0){
			if(playerinfo(j,Player,MAX_NAME_LENGTH)){
				snprintf(Text,MAX_TEXT_LENGTH,"%s^n\w%i:%i -- %s",Text,g_PvPKill[UserID][j],g_PvPKill[j][UserID],Player);
			}
		}
	}
	strcat(Text,"^n^n\y1. Back",MAX_TEXT_LENGTH);
	g_UserMenu[UserID]=7;
	g_UserMenuTime[UserID]=systemtime();
	menu(User,Text,1023,10);
}
 
public HandleMenu(HLCommand,HLData,HLUserName,UserIndex){
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	if(g_UserMenu[UserIndex]!=0){
		if((systemtime()-g_UserMenuTime[UserIndex])<=10){
			g_UserSelectMenu[UserIndex]=strtonum(Data);
			if(g_UserMenu[UserIndex]==1){
				if(g_UserSelectMenu[UserIndex]==1){
					display_statistik(User,UserIndex);
					return PLUGIN_HANDLED;
				}else{
					reset_array(UserIndex);
					return PLUGIN_CONTINUE;
				}
			}else if(g_UserMenu[UserIndex]==2){
				if(g_UserSelectMenu[UserIndex]==1){
					own_statistic(User,UserIndex);
					return PLUGIN_HANDLED;
				}else if (g_UserSelectMenu[UserIndex]==2){
					most_damage(User,UserIndex);
					return PLUGIN_HANDLED;
				}else if (g_UserSelectMenu[UserIndex]==3){
					most_used_weapon(User,UserIndex);
					return PLUGIN_HANDLED;
				}else if (g_UserSelectMenu[UserIndex]==4){
					most_headshots(User,UserIndex);
					return PLUGIN_HANDLED;
				}else if (g_UserSelectMenu[UserIndex]==5){
					best_playerround(User,UserIndex);
					return PLUGIN_HANDLED;
				}else if (g_UserSelectMenu[UserIndex]==6){
					best_playermap(User,UserIndex);
					return PLUGIN_HANDLED;
				}else if (g_UserSelectMenu[UserIndex]==7){
					pvp_statistic(User,UserIndex);
					return PLUGIN_HANDLED;
				}else if(g_UserSelectMenu[UserIndex]==9 && g_PlayerEnemyID[UserIndex]!=0){
					display_victim(User,UserIndex);
					return PLUGIN_HANDLED;
				}else{
					reset_array(UserIndex);
					return PLUGIN_CONTINUE;
				}
			}else{
				if(g_UserSelectMenu[UserIndex]==1){
					display_statistik(User,UserIndex);
					return PLUGIN_HANDLED;
				}else{
					reset_array(UserIndex);
					return PLUGIN_CONTINUE;
				}
			}
		}else{
			reset_array(UserIndex);
			return PLUGIN_CONTINUE;
		}
	}
	return PLUGIN_CONTINUE;
}
 
public SetMenuData(HLCommand,HLData,HLUserName,UserIndex){
	if(g_UserMenu[UserIndex]==1){
		reset_array(UserIndex);
	}
	return PLUGIN_CONTINUE;
}
 
reset_array(UserID){
	g_UserMenu[UserID]=0;
	g_UserSelectMenu[UserID]=0;
	g_UserMenuTime[UserID]=0;
}
 
public plugin_connect(HLUserName,HLIP, UserIndex){
	new i;
	new maxplayers=maxplayercount();
	reset_array(UserIndex);
	for(i=1;i<=maxplayers;i++){
		g_PlayerEnemyInjureTotal[UserIndex][i]=0;
		g_PvPKill[UserIndex][i]=0;
	}
	g_PlayerEnemyInjureTotal[UserIndex][0]=0;
	g_PlayerHS[UserIndex]=0;
	g_PlayerEnemyDistance[UserIndex]=0.000;
	return PLUGIN_CONTINUE;
}
 
public plugin_disconnect(HLUserName,UserIndex){
	new i;
	new maxplayers=maxplayercount();
	new most;
	reset_array(UserIndex);
 
	for(i=1;i<=maxplayers;i++){
		g_PlayerEnemyInjureTotal[UserIndex][i]=0;
		g_PvPKill[UserIndex][i]=0;
 
	}
	if(g_PlayerHSMaxID==UserIndex){
		for(i=1;i<=maxplayers && g_PlayerHSMaxID!=i;i++){
			if(g_PlayerHS[i]!=0){
				if(g_PlayerHS[i]>most){
					most=g_PlayerHS[i];
					g_PlayerHSMaxID=i;
				}
			}
		}
	}
	most=0;
	if(g_BestPlayerRoundID==UserIndex){
		for(i=1;i<=maxplayers && g_BestPlayerRoundID!=i;i++){
			if(g_BestPlayerRound[i]!=0){
				if(g_BestPlayerRound[i]>most){
					most=g_BestPlayerRound[i];
					g_BestPlayerRoundID=i;
				}
			}
		}
	}
	most=0;
	if(g_BestPlayerMapID==UserIndex){
		for(i=1;i<=maxplayers && g_BestPlayerMapID!=i;i++){
			if(g_BestPlayerMap[i]!=0){
				if(g_BestPlayerMap[i]>most){
					most=g_BestPlayerMap[i];
					g_BestPlayerMapID=i;
				}
			}
		}
	}
	/*Zur Sicherheit nochmal wie im connect*/
	for(i=1;i<=maxplayers;i++){
		g_PlayerEnemyInjureTotal[UserIndex][i]=0;
		g_PvPKill[UserIndex][i]=0;
	}
	g_PlayerEnemyInjureTotal[UserIndex][0]=0;
	g_PlayerHS[UserIndex]=0;
	g_PlayerEnemyDistance[UserIndex]=0.000;
	return PLUGIN_CONTINUE;
}
 
/*
quicksort (Array[],lo,hi){
	new i=lo;
	new j=hi;
	new x=Array[(lo+hi)/2];
 
	//  Aufteilung
	while (i<=j)
	{    
	    while (Array[i]<x){
	    	i++; 
	    }
	    while (Array[j]>x){
	    	j--;
	    }
	    if (i<=j){
	        new t=Array[i];
        	Array[i]=Array[j];
        	Array[j]=t;
	        i++; 
	        j--;
	    }
	}
 
	// Rekursion
	if (lo<j){
		quicksort(Array,lo, j);
	}
	if (i<hi){
		quicksort(Array,i, hi);
	}
}*/