[Half-Life AMXX] / kz_ljs_xm.sma Repository:
ViewVC logotype

View of /kz_ljs_xm.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (download) (annotate)
Tue Oct 30 09:08:11 2007 UTC (13 years ago) by ian
File size: 102800 byte(s)
/*
	.-==========================================-.
	|~~ Long Jump Stats - eXtreme Modification ~~|
	.-==========================================-.


	Server cvars:

	===-

	// Enabled/Disables the plugin
	// 0 = disabled
	// 1 = enabled
	kz_ljs_enabled "1"

	// Maximum possible lj (not 4 cj)
	kz_max_lj "260.0"

	// 1337 lj (prints to all players)
	// To disable, set it to -1
	kz_leet_lj "250.0"

	// Professional lj (prints to all players)
	// To disable, set it to -1
	kz_pro_lj "245.0"

	// Good lj (prints to all players)
	// To disable, set it to -1
	kz_good_lj "240.0"

	// Minimal lj distance
	kz_min_lj "215.0"

	// Difrence between longjump and countjump for good/pro/leet/max jump
	kz_cj_dif "5.0"

	// Enables lj sounds
	// 0 = disabled
	// 1 = ultimate sounds
	// 2 = distance in voice
	kz_lj_sounds "1"

	// How dose plugin works
	// 0 = no top and no colorchat
	// 1 = prints good/pro/leet jumps
	// 2 = enables top10
	// 3 = prints good/pro/leet jumps and enables top10
	kz_lj_top "3"

	// Do you want to save ljtop after mapchange?
	kz_ljs_topsave "1"

	// How ranking will work?
	// 0 = names
	// 1 = steam ids
	// 2 = ips
	kz_ljs_rank_by "0"

	// Kz jumping color chat:
	// 0 = normal
	// 1 = red
	// 2 = green
	// 3 = blue
	// 4 = silver
	// 5 = team color

	kz_leet_lj_clr "1"
	kz_pro_lj_clr "2"
	kz_good_lj_clr "4"

	kz_leet_cj_clr "1"
	kz_pro_cj_clr "2"
	kz_good_cj_clr "4"

	// Colors of /ljstats (rrr ggg bbb)
	kz_ljstats_red "0"
	kz_ljstats_green "255"
	kz_ljstats_blue "159"

	// LongJump Stats Laser Beam
	// 0 = off
	// 1 = normal
	// 2 = uber beam
	kz_ljs_beam "2"

	// Enables protection 4 legal kreedz settings
	kz_legal_settings "1"

	// Is your server fast?
	// 0 = slow
	// 1 = normal
	// 2 = realy good ( >10mb/s or localhost/lan server )
	kz_ljs_fastserver "2"

	// Enables auto-setting 4 kz_ljs_fastserver cvar if it is 2
	kz_ljs_autoserver "1"

	// What is enabled on client when he connects to a server?
	// 0 = nothing
	// a = colorchat
	// b = ljstats
	// c = speed
	kz_ljs_connectenabler "abc"

	// Speedometer type
	// 0 = show real speed and horizontal speed
	// 1 = show real speed
	// 2 = show horizontal speed
	kz_ljs_speedtype "0"

	.-==========================================-.


	Admin commands:

	==-

	amx_resetljrec - resets ljrec and ljtop
	amx_resetljtop - resets ljrec and ljtop

	.-==========================================-.


	Client commands:

	==-

	say /colorchat  - enables/disables colorchat
	say /lj10       - display tops menu
	say /ljsmenu    - display ljs menu
	say /ljrec      - prints best longjumper
	say /ljstats    - enables/disables longjump stats
	say /ljsversion - prints plugin version
	say /speed      - enabled/disables visible speed

	.-==========================================-.


	Installation:

	==-

	1. Extract all files and overwrite your cstrike folder
	2. Add kz_ljs_xm.amxx in addons/amxmodx/configs/plugins.ini list
	3. Restart your server/Change map
	!!! WARNING !!!
	To get better gocheck and hook protection write kz_ljs_xm.amxx
	in plugins.ini BEFORE your checkpoint and hook plugins!
	Good e.x. of plugins.ini
	-> kz_ljs_xm.amxx
	-> ProKreedz.amxx
	-> ProKreedz_Hook.amxx
	Bad e.x. of plugins.ini
	-> ProKreedz.amxx
	-> ProKreedz_Hook.amxx
	-> kz_ljs_xm.amxx

	.-==========================================-.


	Credits:

	==-

	Created by:
	Fatalis    ( 8.9.22.42:27017 ) ( http://www.KZMonkeys.net )
	kzlt`Numb  ( profai.sytes.net:27025 ) ( http://www.strike.lt )

	Special thanks to:
	Bentski    ( cs.bentski.lt:27015 ) ( http://kzlt.bentski.lt )
	~Val~      ( cs.groza.ru:27017 ) ( http://www.groza.ru )

	Hosted by:
	http://www.xtreme-jumps.eu/
	http://www.thebishop.fr/

	.-==========================================-.

	Have fun! =]


	P.S. You need legal kreedz settings 4 this to work!!!

*/

#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fakemeta>

#pragma semicolon 1

#define INFO_ZERO 0
#define INFO_ONE 1

// Ints
new idist;
new idist2;
new pluginstatus;
new gBeam;
new strafes[33];
new goodsync[33];
new badsync[33];
new top_names[10][33];
new top_authid[10][33];
new top_distance[10];
new top_maxspeed[10];
new top_prestrafe[10];
new top_strafes[10];
new top_sync[10];
new top_type[10][5];
new cj_names[10][33];
new cj_authid[10][33];
new cj_distance[10];
new cj_maxspeed[10];
new cj_prestrafe[10];
new cj_strafes[10];
new cj_sync[10];
new lj_names[10][33];
new lj_authid[10][33];
new lj_distance[10];
new lj_maxspeed[10];
new lj_prestrafe[10];
new lj_strafes[10];
new lj_sync[10];
new view_names[33][10][33];
new view_distance[33][10];
new view_maxspeed[33][10];
new view_prestrafe[33][10];
new view_strafes[33][10];
new view_sync[33][10];
new view_type[33][10][5];
new full_top_stats_selected_type[33];
new edgefriction;
new mp_footsteps;
new sv_cheats;
new sv_gravity;
new sv_airaccelerate;
new sv_maxspeed;
new sv_stepsize;
new sv_maxvelocity;

// Bools
new bool:tops_save;
new bool:gHasColorChat[33];
new bool:gHasSpeed[33];
new bool:gHasLjStats[33];
new bool:gInAir[33];
new bool:cjumped[33];
new bool:doubleducked[33];
new bool:cducked[33];
new bool:induck[33];
new bool:OnGround[33];
new bool:turning_right[33];
new bool:turning_left[33];
new bool:straifing_aw[33];
new bool:straifing_sd[33];
new bool:menuselect_allowed[33][9];

// Floats
new Float:old_angle1[33];
new Float:angle[3];
new Float:vFramePos[33][2][3];
new Float:vFrameSpeed[33][2][3];
new Float:vBeamPos[33][129][3];
new Float:vBeamPosStatus[33][129];
new Float:vDuckedAt[33][3];
new Float:vJumpedAt[33][3];
new Float:vJumpedAt2[3];
new Float:xDistance;
new Float:yDistance;
new Float:fDistance;
new Float:fDistance1;
new Float:fDistance2;
new Float:rDistance[2];
new Float:rLandPos[3];
new Float:vOrigin[3];
new Float:vOldOrigin[33][3];
new Float:vTraceEnd[3];
new Float:fMaxAirSpeed[33];
new Float:fMaxGroundSpeed[33];
new Float:vVelocity[3];
new Float:fSpeed;
new Float:gSpeed;
new Float:OldSpeed[33];
new Float:frame2time;
new Float:jumptime[33];
new Float:lasttime[33];

// Strings
new const gPLUGIN[] = "LjS - eXtreme Mod";
new const gVERSION[] = "2.17";
new const gAUTHOR[] = "Fatalis & kzlt`Numb";

new MAXPLAYERS;

public plugin_init()
{
	register_plugin(gPLUGIN, gVERSION, gAUTHOR);
	register_cvar("LongJumpStats", gVERSION, FCVAR_SERVER);
	
	register_forward(FM_Touch, "fwdTouch", 1);
	register_forward(FM_PlayerPreThink, "fwdPlayerPreThink", 0);
	register_forward(FM_PlayerPostThink, "fwdPlayerPostThink", 0);
	register_forward(FM_StartFrame, "fwdStartFrame", 0);
	
	register_clcmd("say /colorchat", "cmdColorChat", ADMIN_ALL, "- enables/disables colorchat");
	register_clcmd("say /ljstats", "cmdLjStats", ADMIN_ALL, "- enables/disables longjump stats");
	register_clcmd("say /ljsversion", "cmdVersion", ADMIN_ALL, "- prints plugin version");
	register_clcmd("say /speed", "cmdSpeed", ADMIN_ALL, "- enabled/disables visible speed");
	
	register_cvar("kz_ljs_enabled", "1"); // enables/disables the plugin
	
	register_cvar("kz_good_lj","240.0");   // good longjumps
	register_cvar("kz_pro_lj","245.0");    // professional longjumps
	register_cvar("kz_leet_lj","250.0");   // leet longjump
	register_cvar("kz_min_lj","215.0");    // minimal longjump
	register_cvar("kz_max_lj","260.0");    // maximal longjump
	register_cvar("kz_cj_dif","5.0");      // difrence between lj and cj
	register_cvar("kz_lj_sounds","1");   // enables leet/pro/good lj/cj sounds
	register_cvar("kz_leet_lj_clr","1"); // color of leet lj (1=red, 2=green, 3=blue, 4=gray, 5=team, 0=default)
	register_cvar("kz_pro_lj_clr","2");  // color of pro lj
	register_cvar("kz_good_lj_clr","4"); // color of good lj
	register_cvar("kz_leet_cj_clr","1"); // color of leet lj
	register_cvar("kz_pro_cj_clr","2");  // color of pro lj
	register_cvar("kz_good_cj_clr","4"); // color of good lj
	
	register_cvar("kz_ljstats_red","0");     // red color of /ljstats
	register_cvar("kz_ljstats_green","255"); // green color of /ljstats
	register_cvar("kz_ljstats_blue","159");  // blue color of /ljstats
	
	register_cvar("kz_ljs_beam", "2");	 // 0=beam off, 1=normal beam, 2=uber beam
	
	register_cvar("kz_legal_settings", "1"); // enables protection 4 legal kreedz settings
	
	register_cvar("kz_ljs_autoserver", "1");     // Authomaticaly detect what cvar of kz_ljs_fastserver shold be?
	register_cvar("kz_ljs_speedtype", "0");      // Speedometer type
	register_cvar("kz_ljs_connectenabler", "abc"); // What is enabled at connect (0=nothing, a=colorchat, b=ljstats, c=speed)
	
	register_cvar("kz_lj_top", "3");         // LongJump top (0=Nothing, 1=ColorChat, 2=top, 3=top+ColorChat)
	register_cvar("kz_ljs_topsave", "1");    // Do you want to save ljtop after mapchange?
	register_cvar("kz_ljs_rank_by", "0");    // How ranking will work? 0=name, 1=steam, 2=ip
	
	register_clcmd( "say /ljsmenu", "cmdLjsMenu", ADMIN_ALL, "- display ljs menu");
	register_clcmd( "say /cj15", "cmdTopMenu", -1, "- display tops menu" );
	register_clcmd( "say /cjtop15", "cmdTopMenu", -1, "- display tops menu" );
	register_clcmd( "say /cj10", "cmdTopMenu", ADMIN_ALL, "- display tops menu" );
	register_clcmd( "say /cjtop10", "cmdTopMenu", -1, "- display tops menu" );
	register_clcmd( "say /cjtop", "cmdTopMenu", -1, "- display tops menu" );
	register_clcmd( "say /lj15", "cmdTopMenu", -1, "- display tops menu" );
	register_clcmd( "say /ljtop15", "cmdTopMenu", -1, "- display tops menu" );
	register_clcmd( "say /lj10", "cmdTopMenu", ADMIN_ALL, "- display tops menu" );
	register_clcmd( "say /ljtop10", "cmdTopMenu", -1, "- display tops menu" );
	register_clcmd( "say /ljtop", "cmdTopMenu", -1, "- display tops menu" );
	register_clcmd( "say /ljrec", "show_leet_ljumper", ADMIN_ALL, "- prints best longjump" );
	
	register_clcmd( "say /tele", "gocheck", -1, " - teleported" );
	register_clcmd( "say /tp", "gocheck", -1, " - teleported" );
	register_clcmd( "say /gocheck", "gocheck", -1, " - teleported" );
	register_clcmd( "say /gc", "gocheck", -1, " - teleported" );
	register_clcmd( "say .tele", "gocheck", -1, " - teleported" );
	register_clcmd( "say .tp", "gocheck", -1, " - teleported" );
	register_clcmd( "say .gocheck", "gocheck", -1, " - teleported" );
	register_clcmd( "say .gc", "gocheck", -1, " - teleported" );
	register_clcmd( "/tele", "gocheck", -1, " - teleported" );
	register_clcmd( "/tp", "gocheck", -1, " - teleported" );
	register_clcmd( "/gocheck", "gocheck", -1, " - teleported" );
	register_clcmd( "/gc", "gocheck", -1, " - teleported" );
	register_clcmd( ".tele", "gocheck", -1, " - teleported" );
	register_clcmd( ".tp", "gocheck", -1, " - teleported" );
	register_clcmd( ".gocheck", "gocheck", -1, " - teleported" );
	register_clcmd( ".gc", "gocheck", -1, " - teleported" );
	register_clcmd( "say /start", "gocheck", -1, " - reseted" );
	register_clcmd( "say /reset", "gocheck", -1, " - reseted" );
	register_clcmd( "say /restart", "gocheck", -1, " - reseted" );
	register_clcmd( "say /spawn", "gocheck", -1, " - reseted" );
	register_clcmd( "say .start", "gocheck", -1, " - reseted" );
	register_clcmd( "say .reset", "gocheck", -1, " - reseted" );
	register_clcmd( "say .restart", "gocheck", -1, " - reseted" );
	register_clcmd( "say .spawn", "gocheck", -1, " - reseted" );
	register_clcmd( "/start", "gocheck", -1, " - reseted" );
	register_clcmd( "/reset", "gocheck", -1, " - reseted" );
	register_clcmd( "/restart", "gocheck", -1, " - reseted" );
	register_clcmd( "/spawn", "gocheck", -1, " - reseted" );
	register_clcmd( ".start", "gocheck", -1, " - reseted" );
	register_clcmd( ".reset", "gocheck", -1, " - reseted" );
	register_clcmd( ".restart", "gocheck", -1, " - reseted" );
	register_clcmd( ".spawn", "gocheck", -1, " - reseted" );
	register_clcmd( "+hook", "gocheck", -1, " - used hook" );
	register_clcmd( "-hook", "gocheck", -1, " - used hook" );
	register_clcmd( "say /stuck", "gocheck", -1, " - teleported" );
	register_clcmd( "say /unstuck", "gocheck", -1, " - teleported" );
	register_clcmd( "say .stuck", "gocheck", -1, " - teleported" );
	register_clcmd( "say .unstuck", "gocheck", -1, " - teleported" );
	register_clcmd( "/stuck", "gocheck", -1, " - teleported" );
	register_clcmd( "/unstuck", "gocheck", -1, " - teleported" );
	register_clcmd( ".stuck", "gocheck", -1, " - teleported" );
	register_clcmd( ".unstuck", "gocheck", -1, " - teleported" );
	
	MAXPLAYERS = get_maxplayers( );
	
	edgefriction = get_cvar_pointer("edgefriction");
	mp_footsteps = get_cvar_pointer("mp_footsteps");
	sv_cheats = get_cvar_pointer("sv_cheats");
	sv_gravity = get_cvar_pointer("sv_gravity");
	sv_airaccelerate = get_cvar_pointer("sv_airaccelerate");
	sv_maxspeed = get_cvar_pointer("sv_maxspeed");
	sv_stepsize = get_cvar_pointer("sv_stepsize");
	sv_maxvelocity = get_cvar_pointer("sv_maxvelocity");
	
	set_task(3.0, "editional_init");
	
	exec_ljsconfig();
}

public editional_init()
{
	// Is your server fast? (0=slow, 1=normal, 2=good)
	if( !is_dedicated_server() && get_cvar_num("sv_lan") != 0 && !cvar_exists("kz_ljs_fastserver") && get_cvar_num("kz_ljs_autoserver") )
	{
		register_cvar("kz_ljs_fastserver", "2");
		set_cvar_num("kz_ljs_fastserver", 2);
	}
	else if( !cvar_exists("kz_ljs_fastserver") || ((get_cvar_num("sv_lan") == 0 || is_dedicated_server()) && get_cvar_num("kz_ljs_fastserver") == 2 && get_cvar_num("kz_ljs_autoserver")) )
	{
		register_cvar("kz_ljs_fastserver", "1");
		set_cvar_num("kz_ljs_fastserver", 1);
	}
	
	if( !get_cvar_num("kz_ljs_autoserver") )
		exec_ljsconfig();
	
	// Special tops save
	tops_save = true;
	if( get_cvar_num("kz_ljs_topsave") )
		read_tops();
	else
		tops_save = false;
	
	if ( tops_save )
	{
		register_concmd("amx_resetljrec", "topreset", ADMIN_RCON, "- resets ljrec and ljtops");
		register_concmd("amx_resetljtops", "topreset", ADMIN_RCON, "- resets ljrec and ljtops");
	}
	else
	{
		register_concmd("amx_resetljrec", "topreset", ADMIN_MAP, "- resets ljrec and ljtops");
		register_concmd("amx_resetljtops", "topreset", ADMIN_MAP, "- resets ljrec and ljtops");
	}
		
	register_dictionary("common.txt");
}

public exec_ljsconfig()
{
	static configsDir[64], filename[128];
	get_configsdir(configsDir, 63);
	format(filename, 127, "%s/ljstats.cfg", configsDir);
		
	if( !file_exists(filename) )
	{
		write_file(filename, "// .-==========================================-.");
		write_file(filename, "// |~~ Long Jump Stats - eXtreme Modification ~~|");
		write_file(filename, "// .-==========================================-.");
		write_file(filename, "");
		write_file(filename, "");
		write_file(filename, "// Enabled/Disables the plugin");
		write_file(filename, "// 0 = disabled");
		write_file(filename, "// 1 = enabled");
		write_file(filename, "kz_ljs_enabled ^"1^"");
		write_file(filename, "");
		write_file(filename, "// Maximum possible lj (not 4 cj)");
		write_file(filename, "kz_max_lj ^"260.0^"");
		write_file(filename, "");
		write_file(filename, "// 1337 lj (prints to all players)");
		write_file(filename, "// To disable, set it to -1");
		write_file(filename, "kz_leet_lj ^"250.0^"");
		write_file(filename, "");
		write_file(filename, "// Professional lj (prints to all players)");
		write_file(filename, "// To disable, set it to -1");
		write_file(filename, "kz_pro_lj ^"245.0^"");
		write_file(filename, "");
		write_file(filename, "// Good lj (prints to all players)");
		write_file(filename, "// To disable, set it to -1");
		write_file(filename, "kz_good_lj ^"240.0^"");
		write_file(filename, "");
		write_file(filename, "// Minimal lj distance");
		write_file(filename, "kz_min_lj ^"215.0^"");
		write_file(filename, "");
		write_file(filename, "// Difrence between longjump and countjump for good/pro/leet/max jump");
		write_file(filename, "kz_cj_dif ^"5.0^"");
		write_file(filename, "");
		write_file(filename, "// Enables lj sounds");
		write_file(filename, "// 0 = disabled");
		write_file(filename, "// 1 = ultimate sounds");
		write_file(filename, "// 2 = distance in voice");
		write_file(filename, "kz_lj_sounds ^"1^"");
		write_file(filename, "");
		write_file(filename, "// How dose plugin works");
		write_file(filename, "// 0 = no top and no colorchat");
		write_file(filename, "// 1 = prints good/pro/leet jumps");
		write_file(filename, "// 2 = enables top10");
		write_file(filename, "// 3 = prints good/pro/leet jumps and enables top10");
		write_file(filename, "kz_lj_top ^"3^"");
		write_file(filename, "");
		write_file(filename, "// Do you want to save ljtop after mapchange?");
		write_file(filename, "kz_ljs_topsave ^"1^"");
		write_file(filename, "");
		write_file(filename, "// How ranking will work?");
		write_file(filename, "// 0 = names");
		write_file(filename, "// 1 = steam ids");
		write_file(filename, "// 2 = ips");
		write_file(filename, "kz_ljs_rank_by ^"0^"");
		write_file(filename, "");
		write_file(filename, "// Kz jumping color chat:");
		write_file(filename, "// 0 = normal");
		write_file(filename, "// 1 = red");
		write_file(filename, "// 2 = green");
		write_file(filename, "// 3 = blue");
		write_file(filename, "// 4 = silver");
		write_file(filename, "// 5 = team color");
		write_file(filename, "");
		write_file(filename, "kz_leet_lj_clr ^"1^"");
		write_file(filename, "kz_pro_lj_clr ^"2^"");
		write_file(filename, "kz_good_lj_clr ^"4^"");
		write_file(filename, "");
		write_file(filename, "kz_leet_cj_clr ^"1^"");
		write_file(filename, "kz_pro_cj_clr ^"2^"");
		write_file(filename, "kz_good_cj_clr ^"4^"");
		write_file(filename, "");
		write_file(filename, "// Colors of /ljstats (rrr ggg bbb)");
		write_file(filename, "kz_ljstats_red ^"0^"");
		write_file(filename, "kz_ljstats_green ^"255^"");
		write_file(filename, "kz_ljstats_blue ^"159^"");
		write_file(filename, "");
		write_file(filename, "// LongJump Stats Laser Beam");
		write_file(filename, "// 0 = off");
		write_file(filename, "// 1 = normal");
		write_file(filename, "// 2 = uber beam");
		write_file(filename, "kz_ljs_beam ^"2^"");
		write_file(filename, "");
		write_file(filename, "// Enables protection 4 legal kreedz settings");
		write_file(filename, "kz_legal_settings ^"1^"");
		write_file(filename, "");
		write_file(filename, "// Is your server fast?");
		write_file(filename, "// 0 = slow");
		write_file(filename, "// 1 = normal");
		write_file(filename, "// 2 = realy good ( >10mb/s or localhost/lan server )");
		write_file(filename, "kz_ljs_fastserver ^"2^"");
		write_file(filename, "");
		write_file(filename, "// Enables auto-setting 4 kz_ljs_fastserver cvar if it is 2");
		write_file(filename, "kz_ljs_autoserver ^"1^"");
		write_file(filename, "");
		write_file(filename, "// What is enabled on client when he connects to a server?");
		write_file(filename, "// 0 = nothing");
		write_file(filename, "// a = colorchat");
		write_file(filename, "// b = ljstats");
		write_file(filename, "// c = speed");
		write_file(filename, "kz_ljs_connectenabler ^"abc^"");
		write_file(filename, "");
		write_file(filename, "// Speedometer type");
		write_file(filename, "// 0 = show real speed and horizontal speed");
		write_file(filename, "// 1 = show real speed");
		write_file(filename, "// 2 = show horizontal speed");
		write_file(filename, "kz_ljs_speedtype ^"0^"");
	}
	server_cmd("exec ^"%s^"", filename);
}

public plugin_cfg()
{
	set_cvar_string("edgefriction", "2");
	set_cvar_string("mp_footsteps", "1");
	set_cvar_string("sv_cheats", "0");
	set_cvar_string("sv_gravity", "800");
	set_cvar_string("sv_airaccelerate", "10");
	set_cvar_string("sv_maxspeed", "320");
	set_cvar_string("sv_stepsize", "18");
	set_cvar_string("sv_maxvelocity", "2000");
}

public plugin_precache()
{
	switch(random_num(1,6))
	{
		case 1:
		{
	 		gBeam = precache_model("sprites/zbeam1.spr");
		}
		case 2:
		{
			gBeam = precache_model("sprites/zbeam2.spr");
		}
		case 3:
		{
		 	gBeam = precache_model("sprites/zbeam3.spr");
		}
		case 4:
		{
		 	gBeam = precache_model("sprites/zbeam4.spr");
		}
		case 5:
		{
		 	gBeam = precache_model("sprites/zbeam5.spr");
		}
		case 6:
		{
		 	gBeam = precache_model("sprites/zbeam6.spr");
		}
	}
	
	if( get_cvar_num("kz_lj_sounds") == 1 )
	{
		precache_sound("misc/impressive.wav");
		precache_sound("misc/mod_godlike.wav");
		precache_sound("misc/mod_wickedsick.wav");
		precache_sound("misc/perfect.wav");
	}
	
	if( get_cvar_num("kz_ljs_enabled") )
		pluginstatus = INFO_ONE;
	else
		pluginstatus = INFO_ZERO;
}

public cmdTopMenu(id)
{
	if( get_cvar_num("kz_ljs_enabled") && (get_cvar_num("kz_lj_top") == 2 || get_cvar_num("kz_lj_top") == 3) )
	{
		if( top_distance[0] )
		{
			new MainTopMenu = menu_create("\yTop 10 Menu", "MainTopMenu_Select", 0);
			menu_additem(MainTopMenu, "\wDisplay total top", "1", 0, -1);
			if( !lj_distance[0] )
			{
				menu_additem(MainTopMenu, "\dDisplay lj top (no ljs)", "2", 0, -1);
				menu_additem(MainTopMenu, "\wDisplay cj top^n^n^n\yTops full stats^n", "3", 0, -1);
				menuselect_allowed[id][2] = false;
				menuselect_allowed[id][3] = true;
			}
			else if( !cj_distance[0] )
			{
				menu_additem(MainTopMenu, "\wDisplay lj top", "2", 0, -1);
				menu_additem(MainTopMenu, "\dDisplay cj top (no cjs)^n^n^n\yTops full stats^n", "3", 0, -1);
				menuselect_allowed[id][2] = true;
				menuselect_allowed[id][3] = false;
			}
			else
			{
				menu_additem(MainTopMenu, "\wDisplay lj top", "2", 0, -1);
				menu_additem(MainTopMenu, "\wDisplay cj top^n^n^n\yTops full stats^n", "3", 0, -1);
				menuselect_allowed[id][2] = true;
				menuselect_allowed[id][3] = true;
			}
			
			menu_additem(MainTopMenu, "\wTotal top stats", "4", 0, -1);
			if( !lj_distance[0] )
			{
				menu_additem(MainTopMenu, "\dLj top stats (no ljs)", "5", 0, -1);
				menu_additem(MainTopMenu, "\wCj top stats^n", "6", 0, -1);
				menuselect_allowed[id][5] = false;
				menuselect_allowed[id][6] = true;
			}
			else if( !cj_distance[0] )
			{
				menu_additem(MainTopMenu, "\wLj top stats", "5", 0, -1);
				menu_additem(MainTopMenu, "\dCj top stats (no cjs)^n", "6", 0, -1);
				menuselect_allowed[id][5] = true;
				menuselect_allowed[id][6] = false;
			}
			else
			{
				menu_additem(MainTopMenu, "\wLj top stats", "5", 0, -1);
				menu_additem(MainTopMenu, "\wCj top stats^n", "6", 0, -1);
				menuselect_allowed[id][5] = true;
				menuselect_allowed[id][6] = true;
			}
			menu_display(id, MainTopMenu, 0);
		}
		else
		{
			client_print(id, print_chat, "[XJ] Tops menu is invalid. No jumps were made.");
			//MainTopMenu = menu_create(
			//"\yTop 10 Menu^n^n\r1. \dDisplay total top (no jumps)^n\r2. \dDisplay lj top (no ljs)^n\r3. \dDisplay cj top (no cjs)^n^n\yTops full stats^n^n\r4. \dTotal top stats (no jumps)^n\r5. \dLj top stats (no ljs)^n\r6. \dCj top stats (no cjs)^n",
			//"MainTopMenu_Select", 0);
		}
	}
}

public MainTopMenu_Select(id, menu, item)
{
	if( item == MENU_EXIT )
		menu_destroy(menu);
	
	else if( get_cvar_num("kz_ljs_enabled") && (get_cvar_num("kz_lj_top") == 2 || get_cvar_num("kz_lj_top") == 3) )
	{
		new keycmd[3], _access, callback;
		menu_item_getinfo(menu, item, _access, keycmd, 2, "", 0, callback);
		menu_destroy(menu);
		switch(str_to_num(keycmd))
		{
			case 1: show_top(id, 0);
			case 2:
			{
				if( menuselect_allowed[id][2] )
					show_top(id, 1);
				else
					cmdTopMenu(id);
			}
			case 3:
			{
				if( menuselect_allowed[id][3] )
					show_top(id, 2);
				else
					cmdTopMenu(id);
			}
			case 4: display_full_top_stats_menu(id, 0, 0);
			case 5:
			{
				if( menuselect_allowed[id][5] )
					display_full_top_stats_menu(id, 1, 0);
				else
					cmdTopMenu(id);
			}
			case 6:
			{
				if( menuselect_allowed[id][6] )
					display_full_top_stats_menu(id, 2, 0);
				else
					cmdTopMenu(id);
			}
		}
	}
	else
		menu_destroy(menu);
}

public display_full_top_stats_menu(id, toptype, is_page2)
{
	full_top_stats_selected_type[id] = toptype;
	new i, menuselectview[41], FullTopMenu, menuselect_num, s_menuselect_num[5];
	
	if( toptype == 2 )
	{
		FullTopMenu = menu_create("\yFull cj top stats", "FullTopMenu_Select", 0);
		//menu_setprop(FullTopMenu, MPROP_NUMBER_COLOR, "\r");
		for( i = INFO_ZERO ; i < 10; i++ )
		{
			if( cj_distance[i] )
			{
				menuselect_num += 1;
				num_to_str(menuselect_num, s_menuselect_num, 4);
				format( view_names[id][i], 32, cj_names[i] );
				view_distance[id][i] = cj_distance[i];
				view_maxspeed[id][i] = cj_maxspeed[i];
				view_prestrafe[id][i] = cj_prestrafe[i];
				view_strafes[id][i] = cj_strafes[i];
				view_sync[id][i] = cj_sync[i];
				view_type[id][i] = "";
				format( menuselectview, 40, "\y%d. \w%s \r%d", (i+1), view_names[id][i], (view_distance[id][i]/1000000) );
				menu_additem(FullTopMenu, menuselectview, s_menuselect_num, 0, -1);
			}
			else
			{
				view_names[id][i] = "";
				view_distance[id][i] = 0;
				view_maxspeed[id][i] = 0;
				view_prestrafe[id][i] = 0;
				view_strafes[id][i] = 0;
				view_sync[id][i] = 0;
				view_type[id][i] = "";
			}
		}
	}
	else if( toptype )
	{
		FullTopMenu = menu_create("\yFull lj top stats", "FullTopMenu_Select", 0);
		//menu_setprop(FullTopMenu, MPROP_NUMBER_COLOR, "\r");
		for( i = INFO_ZERO ; i < 10; i++ )
		{
			if( lj_distance[i] )
			{
				menuselect_num += 1;
				num_to_str(menuselect_num, s_menuselect_num, 4);
				format( view_names[id][i], 32, lj_names[i] );
				view_distance[id][i] = lj_distance[i];
				view_maxspeed[id][i] = lj_maxspeed[i];
				view_prestrafe[id][i] = lj_prestrafe[i];
				view_strafes[id][i] = lj_strafes[i];
				view_sync[id][i] = lj_sync[i];
				view_type[id][i] = "";
				format( menuselectview, 40, "\y%d. \w%s \r%d", (i+1), view_names[id][i], (view_distance[id][i]/1000000) );
				menu_additem(FullTopMenu, menuselectview, s_menuselect_num, 0, -1);
			}
			else
			{
				view_names[id][i] = "";
				view_distance[id][i] = 0;
				view_maxspeed[id][i] = 0;
				view_prestrafe[id][i] = 0;
				view_strafes[id][i] = 0;
				view_sync[id][i] = 0;
				view_type[id][i] = "";
			}
		}
	}
	else
	{
		FullTopMenu = menu_create("\yFull total top stats", "FullTopMenu_Select", 0);
		//menu_setprop(FullTopMenu, MPROP_NUMBER_COLOR, "\r");
		for( i = INFO_ZERO ; i < 10; i++ )
		{
			if( top_distance[i] )
			{
				menuselect_num += 1;
				num_to_str(menuselect_num, s_menuselect_num, 4);
				format( view_names[id][i], 32, top_names[i] );
				view_distance[id][i] = top_distance[i];
				view_maxspeed[id][i] = top_maxspeed[i];
				view_prestrafe[id][i] = top_prestrafe[i];
				view_strafes[id][i] = top_strafes[i];
				view_sync[id][i] = top_sync[i];
				format( view_type[id][i], 4, top_type[i] );
				format( menuselectview, 40, "\y%d. \w%s \r%d \d%s", (i+1), view_names[id][i], (view_distance[id][i]/1000000), view_type[id][i] );
				menu_additem(FullTopMenu, menuselectview, s_menuselect_num, 0, -1);
			}
			else
			{
				view_names[id][i] = "";
				view_distance[id][i] = 0;
				view_maxspeed[id][i] = 0;
				view_prestrafe[id][i] = 0;
				view_strafes[id][i] = 0;
				view_sync[id][i] = 0;
				view_type[id][i] = "";
			}
		}
	}
	menu_display(id, FullTopMenu, is_page2);
}

public FullTopMenu_Select(id, menu, item)
{
	if( item == MENU_EXIT )
		menu_destroy(menu);
	else
	{
		new keycmd[3], menuselected_view[41], menuselectview[41],  _access, callback, target, jumpschanged, i;
		menu_item_getinfo(menu, item, _access, keycmd, 2, menuselected_view, 40, callback);
		
		for( i = INFO_ZERO ; i < 10; i++ )
		{
			if( !view_distance[id][i] )
				break;
			
			if( full_top_stats_selected_type[id] )
				format( menuselectview, 40, "\y%d. \w%s \r%d", (i+1), view_names[id][i], (view_distance[id][i]/1000000) );
			else
				format( menuselectview, 40, "\y%d. \w%s \r%d \d%s", (i+1), view_names[id][i], (view_distance[id][i]/1000000), view_type[id][i] );
			
			if( equal(menuselected_view, menuselectview) )
			{
				target = i;
			}
			
			if( full_top_stats_selected_type[id] == 2 && i < 7 )
			{
				if( !equal(view_names[id][i], cj_names[i]) 
				|| view_distance[id][i] != cj_distance[i]
				|| view_maxspeed[id][i] != cj_maxspeed[i]
				|| view_prestrafe[id][i] != cj_prestrafe[i]
				|| view_strafes[id][i] != cj_strafes[i]
				|| view_sync[id][i] != cj_sync[i] )
					jumpschanged = INFO_ONE;
			}
			else if( full_top_stats_selected_type[id] && i < 7 )
			{
				if( !equal(view_names[id][i], lj_names[i]) 
				|| view_distance[id][i] != lj_distance[i]
				|| view_maxspeed[id][i] != lj_maxspeed[i]
				|| view_prestrafe[id][i] != lj_prestrafe[i]
				|| view_strafes[id][i] != lj_strafes[i]
				|| view_sync[id][i] != lj_sync[i] )
					jumpschanged = INFO_ONE;
			}
			else if( i < 7 )
			{
				if( !equal(view_names[id][i], top_names[i]) 
				|| view_distance[id][i] != top_distance[i]
				|| view_maxspeed[id][i] != top_maxspeed[i]
				|| view_prestrafe[id][i] != top_prestrafe[i]
				|| view_strafes[id][i] != top_strafes[i]
				|| view_sync[id][i] != top_sync[i]
				|| !equal(view_type[id][i], top_type[i]) )
					jumpschanged = INFO_ONE;
			}
			
		}
		menu_destroy(menu);
		if( get_cvar_num("kz_ljs_enabled") && (get_cvar_num("kz_lj_top") == 2 || get_cvar_num("kz_lj_top") == 3) )
		{
			show_player_stats(id, target, full_top_stats_selected_type[id]);
			if( full_top_stats_selected_type[id] == 2 )
				view_distance[id][7] = cj_distance[7];
			else if( full_top_stats_selected_type[id] )
				view_distance[id][7] = lj_distance[7];
			else
				view_distance[id][7] = top_distance[7];
			if( (full_top_stats_selected_type[id] == 2 && cj_distance[0])
			|| (full_top_stats_selected_type[id] && lj_distance[0])
			|| (!full_top_stats_selected_type[id] && top_distance[0]) )
			{
				if( str_to_num(keycmd) > 7 && view_distance[id][7] && !jumpschanged )
					display_full_top_stats_menu(id, full_top_stats_selected_type[id], 1);
				else
					display_full_top_stats_menu(id, full_top_stats_selected_type[id], 0);
			}
		}
	}
}

public show_player_stats(id, target, toptype)
{
	new buffer[2368], name[32], len, motdname[64];
	if( toptype == 2 )
		format(motdname, 63, "%s's cj", view_names[id][target]);
	else if( toptype )
		format(motdname, 63, "%s's lj", view_names[id][target]);
	else
		format(motdname, 63, "%s's jump", view_names[id][target]);
	
	len = format(buffer, 2367, "<body bgcolor=#94AEC6><table width=100%% cellpadding=2 cellspacing=0 border=0>");
	len += format(buffer[len], 2367-len, "<tr  align=left bgcolor=#52697B><th width=50%%> Info name <th width=50%% align=left> Value");
	
	format(name, 31, "%s", view_names[id][target]);
	while( containi(name, "<") != -1 )
		replace(name, 63, "<", "&lt;");
	while( containi(name, ">") != -1 )
		replace(name, 63, ">", "&gt;");
	
	if( toptype == 2 )
		len += format(buffer[len], 2367-len, "<tr align=left bgcolor=#A4BED6><td> Top type: <td align=left> CountJump top");
	else if( toptype == 1 )
		len += format(buffer[len], 2367-len, "<tr align=left bgcolor=#A4BED6><td> Top type: <td align=left> LongJump top");
	else
		len += format(buffer[len], 2367-len, "<tr align=left bgcolor=#A4BED6><td> Top type: <td align=left> Total top");
	
	len += format(buffer[len], 2367-len, "<tr align=left><td> Position: <td align=left> #%d", (target+1));
	len += format(buffer[len], 2367-len, "<tr align=left bgcolor=#A4BED6><td> Name: <td align=left> %s", name);
	len += format(buffer[len], 2367-len, "<tr align=left><td> Distance: <td align=left> %d.%06d", (view_distance[id][target]/1000000), (view_distance[id][target]%1000000));
	len += format(buffer[len], 2367-len, "<tr align=left bgcolor=#A4BED6><td> TopSpeed: <td align=left> %d.%06d", (view_maxspeed[id][target]/1000000), (view_maxspeed[id][target]%1000000));
	len += format(buffer[len], 2367-len, "<tr align=left><td> PreStrafe: <td align=left> %d.%06d", (view_prestrafe[id][target]/1000000), (view_prestrafe[id][target]%1000000));
	len += format(buffer[len], 2367-len, "<tr align=left bgcolor=#A4BED6><td> Strafes: <td align=left> %d", view_strafes[id][target]);
	len += format(buffer[len], 2367-len, "<tr align=left><td> Sync: <td align=left> %d", view_sync[id][target]);
	
	if( !toptype )
		len += format(buffer[len], 2367-len, "<tr align=left bgcolor=#A4BED6><td> Jump Type: <td align=left> %s", (equal(view_type[id][target], "cj")) ? "CountJump" : "LongJump");
	
	len += format(buffer[len], 2367-len, "</table></body>");
	
	show_motd(id, buffer, motdname);
}

public cmdLjsMenu(id)
{
	new plugin_cvar = get_cvar_num("kz_ljs_enabled");
	new ljtop_cvar = get_cvar_num("kz_lj_top");
	new LjsMenu = menu_create("\yLongJump Stats Menu", "LjsMenu_Select", 0);
	if( !plugin_cvar )
	{
		menu_additem(LjsMenu, "\dSwitch colorchat (plugin off)", "1", 0, -1);
		menu_additem(LjsMenu, "\dSwitch ljstats (plugin off)", "2", 0, -1);
		menu_additem(LjsMenu, "\dSwitch speed (plugin off)^n", "3", 0, -1);
		menu_additem(LjsMenu, "\dView tops (plugin off)^n", "4", 0, -1);
		menuselect_allowed[id][1] = false;
		menuselect_allowed[id][2] = false;
		menuselect_allowed[id][3] = false;
		menuselect_allowed[id][4] = false;
	}
	//menu_setprop(LjsMenu, MPROP_NUMBER_COLOR, "\r");
	if( plugin_cvar )
	{
		menu_additem(LjsMenu, "\wSwitch colorchat", "1", 0, -1);
		menu_additem(LjsMenu, "\wSwitch ljstats", "2", 0, -1);
		menu_additem(LjsMenu, "\wSwitch speed^n", "3", 0, -1);
		menuselect_allowed[id][1] = true;
		menuselect_allowed[id][2] = true;
		menuselect_allowed[id][3] = true;
		if( (ljtop_cvar == 2 || ljtop_cvar == 3) && top_distance[0] )
		{
			menu_additem(LjsMenu, "\wView tops^n", "4", 0, -1);
			menuselect_allowed[id][4] = true;
		}
		else
		{
			if( !top_distance[0] )
				menu_additem(LjsMenu, "\dView tops (no jumps)^n", "4", 0, -1);
			else
				menu_additem(LjsMenu, "\dView tops (disabled)^n", "4", 0, -1);
			menuselect_allowed[id][4] = false;
		}
	}
	
	new flags = get_user_flags(id);
	if( flags&ADMIN_MENU && (flags&ADMIN_RCON || flags&ADMIN_CVAR) )
		menu_additem(LjsMenu, "\wPrint plugin info^n^n^n\rAdmin menu^n", "5", 0, -1);
	else
		menu_additem(LjsMenu, "\wPrint plugin info^n", "5", 0, -1);
	
	if( flags&ADMIN_RCON && flags&ADMIN_MENU )
	{
		if( flags&ADMIN_CVAR )
		{
			menu_additem(LjsMenu, "\yServer configurations", "6", 0, -1);
			menu_additem(LjsMenu, "\yOne map config^n", "7", 0, -1);
		}
		else
			menu_additem(LjsMenu, "\yServer configurations^n", "6", 0, -1);
	}
	else if( flags&ADMIN_CVAR && flags&ADMIN_MENU )
	{
		menu_additem(LjsMenu, "\yOne map config^n", "7", 0, -1);
	}

	menu_display(id, LjsMenu, 0);
}

public LjsMenu_Select(id, menu, item)
{
	if( item == MENU_EXIT )
		menu_destroy(menu);
	else
	{
		new keycmd[3], _access, callback;
		menu_item_getinfo(menu, item, _access, keycmd, 2, "", 0, callback);
		menu_destroy(menu);
		switch(str_to_num(keycmd))
		{
			case 1:
			{
				if( menuselect_allowed[id][1] && get_cvar_num("kz_ljs_enabled") )
						cmdColorChat(id);
				cmdLjsMenu(id);
			}
			case 2:
			{
				if( menuselect_allowed[id][2] && get_cvar_num("kz_ljs_enabled") )
					cmdLjStats(id);
				cmdLjsMenu(id);
			}
			case 3:
			{
				if( menuselect_allowed[id][3] && get_cvar_num("kz_ljs_enabled") )
					cmdSpeed(id);
				cmdLjsMenu(id);
			}
			case 4:
			{
				if( menuselect_allowed[id][4] )
				{
					if( get_cvar_num("kz_ljs_enabled") )
						cmdTopMenu(id);
				}
				else
					cmdLjsMenu(id);
			}
			case 5: cmdVersion(id);
			case 6: ColorChat(id, RED, "[XJ] Comming soon!");
			case 7: ColorChat(id, BLUE, "[XJ] Comming soon!");
		}
	}
}

public read_tops()
{
	static dataDir[64];
	get_datadir(dataDir, 63);
	
	static test_filename[128], main_filename[128], lj_filename[128], cj_filename[128], version_info[32];
	format(version_info, 31, "Your current version is: %s", gVERSION);
	format(test_filename, 127, "%s/ljtops/folder_test.txt", dataDir);
	format(main_filename, 127, "%s/ljtops/MainTop10.txt", dataDir);
	format(lj_filename, 127, "%s/ljtops/LjTop10.txt", dataDir);
	format(cj_filename, 127, "%s/ljtops/CjTop10.txt", dataDir);
	if( file_exists(test_filename) )
		delete_file(test_filename);
	
	write_file(test_filename, "Testing folder presence...");
	if( file_exists(test_filename) )
	{
		delete_file(test_filename);
		write_file(test_filename, ".-==========================================-.");
		write_file(test_filename, "|~~ Long Jump Stats - eXtreme Modification ~~|");
		write_file(test_filename, ".-==========================================-.");
		write_file(test_filename, "");
		write_file(test_filename, "This file is created in order to test");
		write_file(test_filename, "folder presence for tops to save.");
		write_file(test_filename, "");
		write_file(test_filename, version_info);
		write_file(test_filename, "");
		write_file(test_filename, "You can:");
		write_file(test_filename, "download it/check 4 updates/report bugs/");
		write_file(test_filename, "suggest smt/discuss it");
		write_file(test_filename, "at:");
		write_file(test_filename, "http://xtreme-jumps.eu/forum_viewtopic.php?46.52082.0");
	}
	else
	{
		tops_save = false;
		log_amx("LjS: Error: File <^"%s^"> not found! Disabeling tops save.", test_filename);
		return PLUGIN_HANDLED;
	}
	
	static distance[12], maxspeed[12], prestrafe[12], strafes[6], sync[6], line = 0, txtsize = 0, i;
	if( file_exists(main_filename) )
	{ 
		for( i = INFO_ZERO ; i < 10; i++ )
		{
			if( (line=read_file(main_filename,line,top_names[i],32,txtsize))!=0 )
			{
				if( (line=read_file(main_filename,line,top_authid[i],32,txtsize))!=0 )
				{
					if( (line=read_file(main_filename,line,distance,11,txtsize))!=0 )
					{
						if( (line=read_file(main_filename,line,maxspeed,11,txtsize))!=0 )
						{
							if( (line=read_file(main_filename,line,prestrafe,11,txtsize))!=0 )
							{
								if( (line=read_file(main_filename,line,strafes,5,txtsize))!=0 )
								{
									if( (line=read_file(main_filename,line,sync,5,txtsize))!=0 )
									{
										if( (line=read_file(main_filename,line,top_type[i],4,txtsize))!=0 )
										{
											top_distance[i] = str_to_num( distance );
											top_maxspeed[i] = str_to_num( maxspeed );
											top_prestrafe[i] = str_to_num( prestrafe );
											top_strafes[i] = str_to_num( strafes );
											top_sync[i] = str_to_num( sync );
										}
									}
								}
							}
						}
					}
				}
			}
			else
				break;
		}
	}
	
	line = 0;
	if( file_exists(lj_filename) )
	{ 
		for( i = INFO_ZERO ; i < 10; i++ )
		{
			if( (line=read_file(lj_filename,line,lj_names[i],32,txtsize))!=0 )
			{
				if( (line=read_file(lj_filename,line,lj_authid[i],32,txtsize))!=0 )
				{
					if( (line=read_file(lj_filename,line,distance,11,txtsize))!=0 )
					{
						if( (line=read_file(lj_filename,line,maxspeed,11,txtsize))!=0 )
						{
							if( (line=read_file(lj_filename,line,prestrafe,11,txtsize))!=0 )
							{
								if( (line=read_file(lj_filename,line,strafes,5,txtsize))!=0 )
								{
									if( (line=read_file(lj_filename,line,sync,5,txtsize))!=0 )
									{
										lj_distance[i] = str_to_num( distance );
										lj_maxspeed[i] = str_to_num( maxspeed );
										lj_prestrafe[i] = str_to_num( prestrafe );
										lj_strafes[i] = str_to_num( strafes );
										lj_sync[i] = str_to_num( sync );
									}
								}
							}
						}
					}
				}
			}
			else
				break;
		}
	}
	
	line = 0;
	if( file_exists(cj_filename) )
	{ 
		for( i = INFO_ZERO ; i < 10; i++ )
		{
			if( (line=read_file(cj_filename,line,cj_names[i],32,txtsize))!=0 )
			{
				if( (line=read_file(cj_filename,line,cj_authid[i],32,txtsize))!=0 )
				{
					if( (line=read_file(cj_filename,line,distance,11,txtsize))!=0 )
					{
						if( (line=read_file(cj_filename,line,maxspeed,11,txtsize))!=0 )
						{
							if( (line=read_file(cj_filename,line,prestrafe,11,txtsize))!=0 )
							{
								if( (line=read_file(cj_filename,line,strafes,5,txtsize))!=0 )
								{
									if( (line=read_file(cj_filename,line,sync,5,txtsize))!=0 )
									{
										cj_distance[i] = str_to_num( distance );
										cj_maxspeed[i] = str_to_num( maxspeed );
										cj_prestrafe[i] = str_to_num( prestrafe );
										cj_strafes[i] = str_to_num( strafes );
										cj_sync[i] = str_to_num( sync );
									}
								}
							}
						}
					}
				}
			}
			else
				break;
		}
	}
	return PLUGIN_HANDLED;
}

public topreset(id)
{
	if( id == (is_dedicated_server()?0:1) || (get_user_flags(id)&ADMIN_RCON && tops_save) || (get_user_flags(id)&ADMIN_MAP && !tops_save) )
	{
		static dataDir[64];
		get_datadir(dataDir, 63);
		
		static main_filename[128], lj_filename[128], cj_filename[128];
		format(main_filename, 127, "%s/ljtops/MainTop10.txt", dataDir);
		format(lj_filename, 127, "%s/ljtops/LjTop10.txt", dataDir);
		format(cj_filename, 127, "%s/ljtops/CjTop10.txt", dataDir);
		
		if( file_exists(main_filename) && tops_save )
			delete_file(main_filename);
		if( file_exists(lj_filename) && tops_save )
			delete_file(lj_filename);
		if( file_exists(cj_filename) && tops_save )
			delete_file(cj_filename);
		
		static info_none[33], i;
		info_none = "";
		for( i = INFO_ZERO; i < 10; i++ )
		{
			format( top_names[i], 32, info_none );
			format( top_authid[i], 32, info_none );
			top_distance[i] = INFO_ZERO;
			top_maxspeed[i] = INFO_ZERO;
			top_prestrafe[i] = INFO_ZERO;
			top_strafes[i] = INFO_ZERO;
			top_sync[i] = INFO_ZERO;
			format( top_type[i], 32, info_none );
			
			format( lj_names[i], 32, info_none );
			format( lj_authid[i], 32, info_none );
			lj_distance[i] = INFO_ZERO;
			lj_maxspeed[i] = INFO_ZERO;
			lj_prestrafe[i] = INFO_ZERO;
			lj_strafes[i] = INFO_ZERO;
			lj_sync[i] = INFO_ZERO;
			
			format( cj_names[i], 32, info_none );
			format( cj_authid[i], 32, info_none );
			cj_distance[i] = INFO_ZERO;
			cj_maxspeed[i] = INFO_ZERO;
			cj_prestrafe[i] = INFO_ZERO;
			cj_strafes[i] = INFO_ZERO;
			cj_sync[i] = INFO_ZERO;
		}
		
		static name[32], authid[32];
		name = "";
		authid = "";
		get_user_name( id, name, 31 );
		if( get_cvar_num("kz_ljs_rank_by") == 1 )
			get_user_authid( id, authid ,31 );
		else
			get_user_ip( id, authid, 31, 1);
		
		log_amx("LjS: ^"%s<%d><%s>^" reseted ljtop", name, get_user_userid(id), authid);
		
		console_print(id, "[XJ] LongJump top and rec reseted!");
		client_print(0, print_chat, "[XJ] LongJump top and rec reseted!");
	}
	else
		console_print(id, "%L", id, "NO_ACC_COM");
	return PLUGIN_HANDLED;
}

public check_maintop(id, Distance, MaxAirSpeed, MaxGroundSpeed, strafes, sync, type)
{
	static jumptype[5], editional_top_n, top_num, rankby;
	top_num = 0;
	rankby = get_cvar_num("kz_ljs_rank_by");
	
	static name[32], authid[32];
	get_user_name( id, name, 31 );
	if( rankby == 1 )
		get_user_authid(id, authid ,31);
	else if( rankby == 2 )
		get_user_ip(id, authid, 31, 1);
	else
		get_user_name(id, authid, 31);
	
	if( type )
	{
		editional_top_n = check_cjtop(id, Distance, MaxAirSpeed, MaxGroundSpeed, strafes, sync, rankby);
		jumptype = "cj";
	}
	else
	{
		editional_top_n = check_ljtop(id, Distance, MaxAirSpeed, MaxGroundSpeed, strafes, sync, rankby);
		jumptype = "lj";
	}
	
	if( Distance > top_distance[9] || (Distance == top_distance[9] && equal(top_type[9], "cj") && equal(jumptype, "lj")) )
	{
		static i;
		for( i = INFO_ZERO; i < 10; i++ )
		{
			if( Distance > top_distance[i] || (Distance == top_distance[i] && equal(top_type[i], "cj") && equal(jumptype, "lj")) )
			{
				static pos, j;
				pos = i;
				j = 0;
				while( !equal( top_authid[pos], authid ) && pos < 9 )
					pos++ ;
				for( j = pos; j > i; j-- )
				{
					format( top_names[j], 32, top_names[j-1] );
					format( top_authid[j], 32, top_authid[j-1] );
					top_distance[j] = top_distance[j-1];
					top_maxspeed[j] = top_maxspeed[j-1];
					top_prestrafe[j] = top_prestrafe[j-1];
					top_strafes[j] = top_strafes[j-1];
					top_sync[j] = top_sync[j-1];
					format( top_type[j], 4, top_type[j-1] );
				}
				
				format( top_names[i], 32, name );
				format( top_authid[i], 32, authid );
				top_distance[i] = Distance;
				top_maxspeed[i] = MaxAirSpeed;
				top_prestrafe[i] = MaxGroundSpeed;
				top_strafes[i] = strafes;
				top_sync[i] = sync;
				format( top_type[i], 4, jumptype );
				top_num = i+1;
				
				break;
			}
			else if( equal( top_authid[i], authid ) )
				break;
		}
		if( editional_top_n && (get_cvar_num("kz_lj_top") == 2 || get_cvar_num("kz_lj_top") == 3) )
		{
			if( top_num )
			{
				if( top_num == editional_top_n )
					client_print(0, print_chat, "[XJ] %s now is %d in total & %s top with %d.%03d jump!", name, top_num, jumptype, (Distance/1000000), (Distance%1000000/1000), jumptype);
				else
					client_print(0, print_chat, "[XJ] %s now is %d in total top & %d in %s top with %d jump!", name, top_num, editional_top_n, jumptype, (Distance/1000000), jumptype);
			}
			else
				client_print(0, print_chat, "[XJ] %s now is %d in %s top with %d.%06d jump!", name, editional_top_n, jumptype, (Distance/1000000), (Distance%1000000), jumptype);
		}
	
		if( tops_save && editional_top_n)
			save_tops();
	}
}

public check_cjtop(id, Distance, MaxAirSpeed, MaxGroundSpeed, strafes, sync, rankby)
{
	static name[32], authid[32];
	get_user_name( id, name, 31 );
	if( rankby == 1 )
		get_user_authid(id, authid ,31);
	else if( rankby == 2 )
		get_user_ip(id, authid, 31, 1);
	else
		get_user_name(id, authid, 31);
	
	if( Distance > cj_distance[9] )
	{
		static i;
		for( i = INFO_ZERO; i < 10; i++ )
		{
			if( Distance > cj_distance[i] )
			{
				static pos, j;
				pos = i;
				j = 0;
				while( !equal( cj_authid[pos], authid ) && pos < 9 )
					pos++ ;
				for( j = pos; j > i; j-- )
				{
					format( cj_names[j], 32, cj_names[j-1] );
					format( cj_authid[j], 32, cj_authid[j-1] );
					cj_distance[j] = cj_distance[j-1];
					cj_maxspeed[j] = cj_maxspeed[j-1];
					cj_prestrafe[j] = cj_prestrafe[j-1];
					cj_strafes[j] = cj_strafes[j-1];
					cj_sync[j] = cj_sync[j-1];
				}
				
				format( cj_names[i], 32, name );
				format( cj_authid[i], 32, authid );
				cj_distance[i] = Distance;
				cj_maxspeed[i] = MaxAirSpeed;
				cj_prestrafe[i] = MaxGroundSpeed;
				cj_strafes[i] = strafes;
				cj_sync[i] = sync;
				return (i+1);
				
			}
			else if( equal( cj_authid[i], authid ) )
				return 0;
		}
	}
	return 0;
}

public check_ljtop(id, Distance, MaxAirSpeed, MaxGroundSpeed, strafes, sync, rankby)
{
	static name[32], authid[32];
	get_user_name( id, name, 31 );
	if( rankby == 1 )
		get_user_authid(id, authid ,31);
	else if( rankby == 2 )
		get_user_ip(id, authid, 31, 1);
	else
		get_user_name(id, authid, 31);
	
	if( Distance > lj_distance[9] )
	{
		static i;
		for( i = INFO_ZERO; i < 10; i++ )
		{
			if( Distance > lj_distance[i] )
			{
				static pos, j;
				pos = i;
				j = 0;
				while( !equal( lj_authid[pos], authid ) && pos < 9 )
					pos++ ;
				for( j = pos; j > i; j-- )
				{
					format( lj_names[j], 32, lj_names[j-1] );
					format( lj_authid[j], 32, lj_authid[j-1] );
					lj_distance[j] = lj_distance[j-1];
					lj_maxspeed[j] = lj_maxspeed[j-1];
					lj_prestrafe[j] = lj_prestrafe[j-1];
					lj_strafes[j] = lj_strafes[j-1];
					lj_sync[j] = lj_sync[j-1];
				}
				
				format( lj_names[i], 32, name );
				format( lj_authid[i], 32, authid );
				lj_distance[i] = Distance;
				lj_maxspeed[i] = MaxAirSpeed;
				lj_prestrafe[i] = MaxGroundSpeed;
				lj_strafes[i] = strafes;
				lj_sync[i] = sync;
				return (i+1);
				
			}
			else if( equal( lj_authid[i], authid ) )
				return 0;
		}
	}
	return 0;
}

public save_tops()
{
	static dataDir[64];
	get_datadir(dataDir, 63);
	
	static main_filename[128], lj_filename[128], cj_filename[128];
	format(main_filename, 127, "%s/ljtops/MainTop10.txt", dataDir);
	format(lj_filename, 127, "%s/ljtops/LjTop10.txt", dataDir);
	format(cj_filename, 127, "%s/ljtops/CjTop10.txt", dataDir);
	
	if( file_exists(main_filename) )  
		delete_file(main_filename);
	if( file_exists(lj_filename) )  
		delete_file(lj_filename);
	if( file_exists(cj_filename) )  
		delete_file(cj_filename);
	
	static i, distance[12], maxspeed[12], prestrafe[12], strafes[6], sync[6];
	for( i = INFO_ZERO; i < 10; i++ )
	{
		if( top_distance[i] )
		{
			num_to_str(top_distance[i], distance, 11);
			num_to_str(top_maxspeed[i], maxspeed, 11);
			num_to_str(top_prestrafe[i], prestrafe, 11);
			num_to_str(top_strafes[i], strafes, 5);
			num_to_str(top_sync[i], sync, 5);
			write_file(main_filename, top_names[i]);
			write_file(main_filename, top_authid[i]);
			write_file(main_filename, distance);
			write_file(main_filename, maxspeed);
			write_file(main_filename, prestrafe);
			write_file(main_filename, strafes);
			write_file(main_filename, sync);
			write_file(main_filename, top_type[i]);
		}
		if( lj_distance[i] )
		{
			num_to_str(lj_distance[i], distance, 11);
			num_to_str(lj_maxspeed[i], maxspeed, 11);
			num_to_str(lj_prestrafe[i], prestrafe, 11);
			num_to_str(lj_strafes[i], strafes, 5);
			num_to_str(lj_sync[i], sync, 5);
			write_file(lj_filename, lj_names[i]);
			write_file(lj_filename, lj_authid[i]);
			write_file(lj_filename, distance);
			write_file(lj_filename, maxspeed);
			write_file(lj_filename, prestrafe);
			write_file(lj_filename, strafes);
			write_file(lj_filename, sync);
		}
		if( cj_distance[i] )
		{
			num_to_str(cj_distance[i], distance, 11);
			num_to_str(cj_maxspeed[i], maxspeed, 11);
			num_to_str(cj_prestrafe[i], prestrafe, 11);
			num_to_str(cj_strafes[i], strafes, 5);
			num_to_str(cj_sync[i], sync, 5);
			write_file(cj_filename, cj_names[i]);
			write_file(cj_filename, cj_authid[i]);
			write_file(cj_filename, distance);
			write_file(cj_filename, maxspeed);
			write_file(cj_filename, prestrafe);
			write_file(cj_filename, strafes);
			write_file(cj_filename, sync);
		}
	}
}

public show_leet_ljumper(id)
{
	if( get_cvar_num("kz_ljs_enabled") && (get_cvar_num("kz_lj_top") == 2 || get_cvar_num("kz_lj_top") == 3) )
	{
		if( top_distance[0] )
			client_print(id, print_chat, "[XJ] %s has the %d.%06d %s record!", top_names[0], top_distance[0]/1000000, top_distance[0]%1000000, top_type[0]);
		else
			client_print(id, print_chat, "[XJ] LongJump record not setted!");
	}
}

public show_top(id, toptype)
{
	static buffer[2368], name[64], len, i;
	
	len = format(buffer, 2367, "<body bgcolor=#94AEC6><table width=100%% cellpadding=2 cellspacing=0 border=0>");
	if( !toptype )
		len += format(buffer[len], 2367-len, "<tr  align=center bgcolor=#52697B><th width=5%%> # <th width=34%% align=left> Name <th width=10%%> Distance <th  width=10%%> MaxSpeed <th  width=11%%> PreStrafe <th  width=9%%> Strafes <th  width=6%%> Sync <th  width=10%%> Type");
	else
		len += format(buffer[len], 2367-len, "<tr  align=center bgcolor=#52697B><th width=5%%> # <th width=34%% align=left> Name <th width=10%%> Distance <th  width=10%%> MaxSpeed <th  width=11%%> PreStrafe <th  width=9%%> Strafes <th  width=6%%> Sync");
	
	if( toptype == 2)
	{
		for( i = INFO_ZERO; i < 10; i++ )
		{		
			if( cj_distance[i] == 0 )
			{
				len += format(buffer[len], 2367-len, "<tr align=center%s><td> %d <td align=left> %s <td> %s <td> %s <td> %s <td> %s <td> %s", ((i%2)==0) ? "" : " bgcolor=#A4BED6", (i+1), "-", "-", "-", "-", "-", "-");
				i=10;
			}
			else
			{
				name = cj_names[i];
				while( containi(name, "<") != -1 )
					replace(name, 63, "<", "&lt;");
				while( containi(name, ">") != -1 )
					replace(name, 63, ">", "&gt;");
				len += format(buffer[len], 2367-len, "<tr align=center%s><td> %d <td align=left> %s <td> %d.%01d <td> %d.%01d <td> %d.%01d <td> %d <td> %d", ((i%2)==0) ? "" : " bgcolor=#A4BED6", (i+1), name, (cj_distance[i]/1000000), (cj_distance[i]%1000000/100000), (cj_maxspeed[i]/1000000), (cj_maxspeed[i]%1000000/100000), (cj_prestrafe[i]/1000000), (cj_prestrafe[i]%1000000/100000), cj_strafes[i], cj_sync[i]);
			}
		}
	}
	else if( toptype )
	{
		for( i = INFO_ZERO; i < 10; i++ )
		{		
			if( lj_distance[i] == 0 )
			{
				len += format(buffer[len], 2367-len, "<tr align=center%s><td> %d <td align=left> %s <td> %s <td> %s <td> %s <td> %s <td> %s", ((i%2)==0) ? "" : " bgcolor=#A4BED6", (i+1), "-", "-", "-", "-", "-", "-");
				i=10;
			}
			else
			{
				name = lj_names[i];
				while( containi(name, "<") != -1 )
					replace(name, 63, "<", "&lt;");
				while( containi(name, ">") != -1 )
					replace(name, 63, ">", "&gt;");
				len += format(buffer[len], 2367-len, "<tr align=center%s><td> %d <td align=left> %s <td> %d.%01d <td> %d.%01d <td> %d.%01d <td> %d <td> %d", ((i%2)==0) ? "" : " bgcolor=#A4BED6", (i+1), name, (lj_distance[i]/1000000), (lj_distance[i]%1000000/100000), (lj_maxspeed[i]/1000000), (lj_maxspeed[i]%1000000/100000), (lj_prestrafe[i]/1000000), (lj_prestrafe[i]%1000000/100000), lj_strafes[i], lj_sync[i]);
			}
		}
	}
	else
	{
		for( i = INFO_ZERO; i < 10; i++ )
		{		
			if( top_distance[i] == 0 )
			{
				len += format(buffer[len], 2367-len, "<tr align=center%s><td> %d <td align=left> %s <td> %s <td> %s <td> %s <td> %s <td> %s <td> %s", ((i%2)==0) ? "" : " bgcolor=#A4BED6", (i+1), "-", "-", "-", "-", "-", "-", "-");
				i=10;
			}
			else
			{
				name = top_names[i];
				while( containi(name, "<") != -1 )
					replace(name, 63, "<", "&lt;");
				while( containi(name, ">") != -1 )
					replace(name, 63, ">", "&gt;");
				len += format(buffer[len], 2367-len, "<tr align=center%s><td> %d <td align=left> %s <td> %d <td> %d <td> %d <td> %d <td> %d <td> %s", ((i%2)==0) ? "" : " bgcolor=#A4BED6", (i+1), name, (top_distance[i]/1000000), (top_maxspeed[i]/1000000), (top_prestrafe[i]/1000000), top_strafes[i], top_sync[i], top_type[i]);
			}
		}
	}
		
	len += format(buffer[len], 2367-len, "</table></body>");
	
	if( toptype == 2)
		show_motd(id, buffer, "Top 10 CountJumps");
	else if( toptype )
		show_motd(id, buffer, "Top 10 LongJumps");
	else
		show_motd(id, buffer, "Top 10 Best Jumps");
}

public gocheck(id)
{
	gInAir[id] = false;
	cjumped[id] = false;
	doubleducked[id] = false;
}

public ddend(id)
	doubleducked[id] = false;

public testcjstart(id)
	cducked[id] = false;

public client_putinserver(id)
{
	static connectenabler[6], fastserver;
	fastserver = get_cvar_num("kz_ljs_fastserver");
	get_cvar_string("kz_ljs_connectenabler", connectenabler, 5);
	format(connectenabler, 5, "_%s", connectenabler);
	if( contain(connectenabler, "a") > 0 )
		gHasColorChat[id] = true;
	else
		gHasColorChat[id] = false;
	if( contain(connectenabler, "b") > 0 )
		gHasLjStats[id] = true;
	else
		gHasLjStats[id] = false;
	if( contain(connectenabler, "c") > 0 )
	{
		gHasSpeed[id] = true;
		if( fastserver == 1 )
			set_task(0.1, "tskSpeed", id+334490, "", 0, "b", 0);
		else if( !(fastserver == 2) )
			set_task(0.5, "tskSpeed", id+334490, "", 0, "b", 0);
	}
	else
		gHasSpeed[id] = false;
	
	if( fastserver == 2 )
		set_task(0.5, "tskFps", id+434490, "", 0, "b", 0);
	else
		set_task(1.0, "tskFps", id+434490, "", 0, "b", 0);
	
	turning_right[id] = false;
	turning_left[id] = false;
	straifing_aw[id] = false;
	straifing_sd[id] = false;
	cducked[id] = false;
	cjumped[id] = false;
	doubleducked[id]=false;
	induck[id] = false;
	OnGround[id] = false;
}

public client_disconnect(id)
{
	gHasColorChat[id] = false;
	gHasLjStats[id] = false;
	gHasSpeed[id] = false;
	turning_right[id] = false;
	turning_left[id] = false;
	straifing_aw[id] = false;
	straifing_sd[id] = false;
	OnGround[id] = false;
	cducked[id] = false;
	doubleducked[id]=false;
	cjumped[id] = false;
	induck[id] = false;
	
	if( task_exists(id+334490, 0) )
		remove_task(id+334490, 0);
	
	if( task_exists(id+434490, 0) )
		remove_task(id+434490, 0);
}

public tskFps(id)
{
	if( get_cvar_num("kz_legal_settings") && get_cvar_num("kz_ljs_enabled") )
	{
		id-=434490;
		client_cmd(id, "developer 0;fps_max 101");
	}
}

public cmdColorChat(id)
{
	if( get_cvar_num("kz_ljs_enabled") && !gHasColorChat[id] )
	{
		gHasColorChat[id] = true;
		client_print(id, print_chat, "[XJ] ColorChat enabled. To disable, type /colorchat.");
	}
	else if( get_cvar_num("kz_ljs_enabled") )
	{
		gHasColorChat[id] = false;
		client_print(id, print_chat, "[XJ] ColorChat disabled. To enable, type /colorchat.");
	}
	
	return PLUGIN_CONTINUE;
}

public cmdLjStats(id)
{
	if( get_cvar_num("kz_ljs_enabled") && !gHasLjStats[id] )
	{
		gHasLjStats[id] = true;
		
		client_print(id, print_chat, "[XJ] LongJump Stats enabled. To disable, type /ljstats.");
	}
	else if( get_cvar_num("kz_ljs_enabled") )
	{
		gHasLjStats[id] = false;
		
		client_print(id, print_chat, "[XJ] LongJump Stats disabled. To enable, type /ljstats.");
	}
	
	return PLUGIN_CONTINUE;
}

public cmdSpeed(id)
{
	if( get_cvar_num("kz_ljs_enabled") && !gHasSpeed[id] )
	{
		gHasSpeed[id] = true;
		if( get_cvar_num("kz_ljs_fastserver") == 1 )
			set_task(0.1, "tskSpeed", id+334490, "", 0, "b", 0);
		else if( !(get_cvar_num("kz_ljs_fastserver") == 2) )
			set_task(0.5, "tskSpeed", id+334490, "", 0, "b", 0);
		client_print(id, print_chat, "[XJ] Speedometer enabled. To disable, type /speed.");
	}
	else if( get_cvar_num("kz_ljs_enabled") )
	{
		gHasSpeed[id] = false;
		if( task_exists(id+334490, 0) )
			remove_task(id+334490, 0);
		client_print(id, print_chat, "[XJ] Speedometer disabled. To enable, type /speed.");
	}
	
	return PLUGIN_CONTINUE;
}

public tskSpeed(taskid)
{
	taskid-=334490;
	static alive, aliveflags, spectatedplayer, specflags;
	alive = is_user_alive(taskid);
	aliveflags = pev(taskid, pev_flags);
	spectatedplayer = get_spectated_player(taskid);
	specflags = pev(spectatedplayer, pev_flags);
	
	if( (alive || spectatedplayer > 0) && get_cvar_num("kz_ljs_enabled") )
	{
		if( alive )
		{
			pev(taskid, pev_velocity, vVelocity);
			if( aliveflags&FL_ONGROUND && aliveflags&FL_INWATER )
				vVelocity[2]-=vVelocity[2];
		}
		else
		{
			pev(spectatedplayer, pev_velocity, vVelocity);
			if( specflags&FL_ONGROUND && specflags&FL_INWATER )
				vVelocity[2]-=vVelocity[2];
		}
				
		if( get_cvar_num("kz_ljs_fastserver") == 1 )
			set_hudmessage(255, 255, 255, -1.0, 0.65, 0, 0.0, 0.2, 0.0, 0.0, 2);
		else if( !(get_cvar_num("kz_ljs_fastserver") == 1 || get_cvar_num("kz_ljs_fastserver") == 2) )
			set_hudmessage(255, 255, 255, -1.0, 0.65, 0, 0.0, 0.6, 0.0, 0.0, 2);
		
		if( get_cvar_num("kz_ljs_speedtype") == 1 )
		{
			idist = floatround(vector_length(vVelocity), floatround_floor);
			show_hudmessage(taskid, "%d units/second", idist);
		}
		else if( get_cvar_num("kz_ljs_speedtype") == 2 )
		{
			if( !(vVelocity[2] == 0) )
				vVelocity[2]-=vVelocity[2];
			gSpeed = vector_length(vVelocity);
			idist2 = floatround(gSpeed, floatround_floor);
			show_hudmessage(taskid, "%d velocity", idist2);
		}
		else
		{
			if( !(vVelocity[2] == 0) )
				vVelocity[2]-=vVelocity[2];
			gSpeed = vector_length(vVelocity);
			if( alive )
			{
				pev(taskid, pev_velocity, vVelocity);
				if( aliveflags&FL_ONGROUND && aliveflags&FL_INWATER )
					vVelocity[2]-=vVelocity[2];
			}
			else
			{
				pev(spectatedplayer, pev_velocity, vVelocity);
				if( specflags&FL_ONGROUND && specflags&FL_INWATER )
					vVelocity[2]-=vVelocity[2];
			}
			idist = floatround(vector_length(vVelocity), floatround_floor);
			idist2 = floatround(gSpeed, floatround_floor);
			show_hudmessage(taskid, "%d units/second^n%d velocity", idist, idist2);
		}
	}
}

public cmdVersion(id)
{
	ColorChat(id, GREY, "^x04[XJ] Plugin: ^x01%s^x04 by: ^x03%s", gPLUGIN, gAUTHOR);
	if( get_cvar_num("kz_ljs_enabled") )
		ColorChat(id, BLUE, "^x04[XJ] Version: ^x01%s^x04, Status:^x03 enabled", gVERSION);
	else
		ColorChat(id, RED, "^x04[XJ] Version: ^x01%s^x04, Status:^x03 disabled", gVERSION);
}

public fwdStartFrame()
{
	if( get_cvar_num("kz_legal_settings") && get_cvar_num("kz_ljs_enabled") )
	{
		if( get_pcvar_num(edgefriction) != 2 )
			set_pcvar_num(edgefriction, 2);
		
		if( get_pcvar_num(mp_footsteps) != 1 )
			set_pcvar_num(mp_footsteps, 1);
		
		if( get_pcvar_num(sv_cheats) != 0 )
			set_pcvar_num(sv_cheats, 0);
		
		if( get_pcvar_num(sv_gravity) != 800 )
			set_pcvar_num(sv_gravity, 800);
		
		if( get_pcvar_num(sv_airaccelerate) != 10 )
			set_pcvar_num(sv_airaccelerate, 10);
		
		if( get_pcvar_num(sv_maxspeed) != 320 )
			set_pcvar_num(sv_maxspeed, 320);
		
		if( get_pcvar_num(sv_stepsize) != 18 )
			set_pcvar_num(sv_stepsize, 18);
		
		if( get_pcvar_num(sv_maxvelocity) != 2000 )
			set_pcvar_num(sv_maxvelocity, 2000);
	}
	
	if( FindPlayer() > -1)
	{
		if( get_cvar_num("kz_ljs_enabled") )
		{
			set_hudmessage(255, 255, 255, -1.0, 0.65, 0, 0.0, 0.1, 0.0, 0.0, 2);
			if( !(pluginstatus) )
			{
				ColorChat(0, BLUE, "^x04[XJ] ^x01%s ^x04plugin^x03 enabled ^x04!", gPLUGIN);
				pluginstatus = INFO_ONE;
			}
		}
		else
		{
			if( pluginstatus )
			{
				ColorChat(0, RED, "^x04[XJ] ^x01%s ^x04plugin^x03 disabled ^x04!", gPLUGIN);
				pluginstatus = INFO_ZERO;
			}
		}
	}
	static id, fastserver, speedtype, spectatedplayer, alive, aliveflags, specflags;
	fastserver = get_cvar_num("kz_ljs_fastserver");
	speedtype = get_cvar_num("kz_ljs_speedtype");
	for( id = INFO_ONE; 0 < id <= MAXPLAYERS; id++ )
	{
		spectatedplayer = get_spectated_player(id);
		alive = is_user_alive(id);
		aliveflags = pev(id, pev_flags);
		specflags = pev(spectatedplayer, pev_flags);
		if( pev_valid(id) && (alive || spectatedplayer > 0) && pluginstatus )
		{
			if( alive )
			{
				pev(id, pev_velocity, vVelocity);
				if( aliveflags&FL_ONGROUND && aliveflags&FL_INWATER )
					vVelocity[2]-=vVelocity[2];
			}
			else
			{
				pev(spectatedplayer, pev_velocity, vVelocity);
				if( specflags&FL_ONGROUND && specflags&FL_INWATER )
					vVelocity[2]-=vVelocity[2];
			}
			
			if( fastserver == 2 && gHasSpeed[id] )
			{
				if( task_exists(id+334490, 0) )
					remove_task(id+334490, 0);
				
				if( speedtype == 1 )
				{
					idist = floatround(vector_length(vVelocity), floatround_floor);
					show_hudmessage(id, "%d units/second", idist);
				}
				else if( speedtype == 2 )
				{
					if( !(vVelocity[2] == 0) )
						vVelocity[2]-=vVelocity[2];
					gSpeed = vector_length(vVelocity);
					idist2 = floatround(gSpeed, floatround_floor);
					show_hudmessage(id, "%d velocity", idist2);
				}
				else
				{
					if( !(vVelocity[2] == 0) )
						vVelocity[2]-=vVelocity[2];
					gSpeed = vector_length(vVelocity);
					if( alive )
					{
						pev(id, pev_velocity, vVelocity);
						if( aliveflags&FL_ONGROUND && aliveflags&FL_INWATER )
							vVelocity[2]-=vVelocity[2];
					}
					else
					{
						pev(spectatedplayer, pev_velocity, vVelocity);
						if( specflags&FL_ONGROUND && specflags&FL_INWATER )
							vVelocity[2]-=vVelocity[2];
					}
					idist = floatround(vector_length(vVelocity), floatround_floor);
					idist2 = floatround(gSpeed, floatround_floor);
					show_hudmessage(id, "%d units/second^n%d velocity", idist, idist2);
				}			
			}
			else if( gHasSpeed[id]
			&& !(fastserver == 2)
			&& !(task_exists(id+334490, 0)) )
			{
				if( fastserver == 1 )
					set_task(0.1, "tskSpeed", id+334490, "", 0, "b", 0);
				else if( !(fastserver == 2) )
					set_task(0.5, "tskSpeed", id+334490, "", 0, "b", 0);
			}
		}
	}
}

public fwdPlayerPreThink(id)
{
	if( is_user_alive(id) && get_cvar_num("kz_ljs_enabled") )
	{
		static flags, buttons, oldbuttons;
		flags = pev(id, pev_flags);
		buttons = pev(id, pev_button);
		oldbuttons = pev(id, pev_oldbuttons);
		
		static Float:fGravity;
		pev(id, pev_gravity, fGravity);
		
		pev(id, pev_angles, angle);
		old_angle1[id] = angle[1];
		
		if( buttons&IN_MOVERIGHT
		|| buttons&IN_MOVELEFT
		|| buttons&IN_FORWARD
		|| buttons&IN_BACK )
		{
			pev(id, pev_velocity, vVelocity);
			if( !(vVelocity[2] == 0) )
				vVelocity[2]-=vVelocity[2];
			if( vector_length(vVelocity) > OldSpeed[id] )
				goodsync[id] += INFO_ONE;
			else
				badsync[id] += INFO_ONE;
		}
		pev(id, pev_velocity, vVelocity);
		if( !(vVelocity[2] == 0) )
			vVelocity[2]-=vVelocity[2];
		OldSpeed[id] = vector_length(vVelocity);
		
		if( gInAir[id] == true && !(flags&FL_ONGROUND) )
		{
			static i;
			for( i = INFO_ZERO; i < 2; i++ )
			{
				if( (vFramePos[id][i][0] == 0
				&& vFramePos[id][i][1] == 0
				&& vFramePos[id][i][2] == 0
				&& vFrameSpeed[id][i][0] == 0
				&& vFrameSpeed[id][i][1] == 0
				&& vFrameSpeed[id][i][2] == 0)
				|| (i == 1) )
				{
					pev(id, pev_origin, vOrigin);
					vFramePos[id][i][0] = vOrigin[0];
					vFramePos[id][i][1] = vOrigin[1];
					vFramePos[id][i][2] = vOrigin[2];
					
					pev(id, pev_velocity, vVelocity);
					vFrameSpeed[id][i][0] = vVelocity[0];
					vFrameSpeed[id][i][1] = vVelocity[1];
					vFrameSpeed[id][i][2] = vVelocity[2];
					
					i=2;
				}
			}
		}
		
		pev(id, pev_velocity, vVelocity);
		if( flags&FL_ONGROUND && flags&FL_INWATER )
			vVelocity[2]-=vVelocity[2];
		fSpeed = vector_length(vVelocity);
		
		pev(id, pev_origin, vOrigin);
		fDistance = get_distance_f(vOldOrigin[id], vOrigin);
		pev(id, pev_origin, vOldOrigin[id]);
		pev(id, pev_velocity, vVelocity);
		if( !(vVelocity[2] == 0) )
			vVelocity[2]-=vVelocity[2];
		
		if( (cjumped[id] == false
		&& vector_length(vVelocity) > 345.0)
		|| (cjumped[id] == true
		&& vector_length(vVelocity) > 352.5)
		|| pev(id, pev_maxspeed) != 250.0
		|| pev(id, pev_movetype) != MOVETYPE_WALK
		|| fGravity != 1.0
		|| get_pcvar_num(edgefriction) != 2
		|| get_pcvar_num(mp_footsteps) != 1
		|| get_pcvar_num(sv_cheats) != 0
		|| get_pcvar_num(sv_gravity) != 800
		|| get_pcvar_num(sv_airaccelerate) != 10
		|| get_pcvar_num(sv_maxspeed) != 320
		|| get_pcvar_num(sv_stepsize) != 18
		|| get_pcvar_num(sv_maxvelocity) != 2000
		|| pev(id, pev_waterlevel) >= 2
		|| fDistance > 20 )
		{
			gocheck(id);
			return FMRES_IGNORED;
		}
		
		if( !(flags&FL_ONGROUND) )
			lasttime[id] = get_gametime();
		
		if( gInAir[id] == true )
		{
			pev(id, pev_velocity, vVelocity);
			if( !(vVelocity[2] == 0) )
				vVelocity[2]-=vVelocity[2];
			gSpeed = vector_length(vVelocity);
			if( gSpeed > fMaxAirSpeed[id] )
			{
				fMaxAirSpeed[id] = gSpeed;
			}
		}
		
		if( buttons&IN_JUMP
		&& !(oldbuttons&IN_JUMP)
		&& flags&FL_ONGROUND
		&& gInAir[id] == false )
		{
			set_task(0.8,"gocheck", id);
			
			jumptime[id] = get_gametime();
			gInAir[id] = true;
			fMaxGroundSpeed[id] = fSpeed;
			OldSpeed[id] = fSpeed;
			fMaxAirSpeed[id] = fSpeed;
			
			pev(id, pev_origin, vOrigin);
			
			vJumpedAt[id][0] = vOrigin[0];
			vJumpedAt[id][1] = vOrigin[1];
			vJumpedAt[id][2] = vOrigin[2];
			
			if( doubleducked[id] == true && vOrigin[2] == vDuckedAt[id][2] )
				cjumped[id] = true;
			else
				cjumped[id] = false;
			
			doubleducked[id] = false;
			
			strafes[id] = INFO_ZERO;
			
			goodsync[id] = INFO_ZERO;
			badsync[id] = INFO_ZERO;
			
			turning_right[id] = false;
			turning_left[id] = false;
			straifing_aw[id] = false;
			straifing_sd[id] = false;
			if( cjumped[id] == false )
			{
				static i;
				for( i = INFO_ZERO; i < 127; i++ )
				{
					vBeamPos[id][i][0] = vOrigin[0]-vOrigin[0];
					vBeamPos[id][i][1] = vOrigin[1]-vOrigin[1];
					vBeamPos[id][i][2] = vOrigin[2]-vOrigin[2];
				}
			}
			static i;
			for( i = INFO_ZERO; i < 2; i++ )
			{
				vFramePos[id][i][0] = vOrigin[0]-vOrigin[0];
				vFramePos[id][i][1] = vOrigin[1]-vOrigin[1];
				vFramePos[id][i][2] = vOrigin[2]-vOrigin[2];
				
				vFrameSpeed[id][i][0] = vOrigin[0]-vOrigin[0];
				vFrameSpeed[id][i][1] = vOrigin[1]-vOrigin[1];
				vFrameSpeed[id][i][2] = vOrigin[2]-vOrigin[2];
			}
		}
		else if( flags&FL_ONGROUND
		&& gInAir[id] == true )
		{
			set_task(0.5,"gocheck", id);
			gInAir[id] = false;
			
			pev(id, pev_origin, vOrigin);
			
			fDistance1 = get_distance_f(vJumpedAt[id], vOrigin)+32.0625;
			
			if( !(vFramePos[id][0][2] > vOrigin[2]) )
				return FMRES_IGNORED;
			
			rLandPos[2] = vFrameSpeed[id][0][2] * vFrameSpeed[id][0][2] + (2 * get_pcvar_float(sv_gravity) * (vFramePos[id][0][2] - vOrigin[2]));
			rDistance[0] = (floatsqroot(rLandPos[2]) * -1) - vFrameSpeed[id][1][2];
			rDistance[1] = get_pcvar_float(sv_gravity)*-1;
			frame2time = floatdiv(rDistance[0], rDistance[1]);
			
			if( vFrameSpeed[id][1][0] < 0 )
				vFrameSpeed[id][1][0] = vFrameSpeed[id][1][0]*-1;
			rDistance[0] = frame2time*vFrameSpeed[id][1][0];
			
			if( vFrameSpeed[id][1][1] < 0 )
				vFrameSpeed[id][1][1] = vFrameSpeed[id][1][1]*-1;
			rDistance[1] = frame2time*vFrameSpeed[id][1][1];
			
			if( vFramePos[id][1][0] < vOrigin[0] )
				rLandPos[0] = vFramePos[id][1][0] + rDistance[0];
			else
				rLandPos[0] = vFramePos[id][1][0] - rDistance[0];
			
			if( vFramePos[id][1][1] < vOrigin[1] )
				rLandPos[1] = vFramePos[id][1][1] + rDistance[1];
			else
				rLandPos[1] = vFramePos[id][1][1] - rDistance[1];
			
			if( is_in_duck(id) )
				vOrigin[2]+=18.0;
			rLandPos[2] = vOrigin[2];
			
			frame2time += (lasttime[id]-jumptime[id]);
			if( vOrigin[2] == vJumpedAt[id][2] )
			{
				if( is_in_duck(id) && !(frame2time > 0.71 && frame2time < 0.77) )
					vOrigin[2] = vOrigin[2]*-1;
				else if( !(is_in_duck(id)) && !(frame2time > 0.65 && frame2time < 0.70) )
					vOrigin[2] = vOrigin[2]*-1;
			}
			
			fDistance2 = get_distance_f(vJumpedAt[id], rLandPos)+32.0625;
			if( fDistance1 > fDistance2 )
			{
				fDistance = fDistance2;
				vOrigin[0] = rLandPos[0];
				vOrigin[1] = rLandPos[1];
			}
			else
				fDistance = fDistance1;
			
			vJumpedAt2[2] = vJumpedAt[id][2]-34.0;
			vTraceEnd[2] = vOrigin[2]-34.0;
			
			vJumpedAt2[0] = vJumpedAt[id][0];
			vTraceEnd[0] = vOrigin[0];
			vJumpedAt2[1] = vJumpedAt[id][1]-vJumpedAt[id][1];
			vTraceEnd[1] = vOrigin[1]-vOrigin[1];
			xDistance = get_distance_f(vJumpedAt2, vTraceEnd);
			
			vJumpedAt2[0] = vJumpedAt[id][0]-vJumpedAt[id][0];
			vTraceEnd[0] = vOrigin[0]-vOrigin[0];
			vJumpedAt2[1] = vJumpedAt[id][1];
			vTraceEnd[1] = vOrigin[1];
			yDistance = get_distance_f(vJumpedAt2, vTraceEnd);
			
			if( vJumpedAt[id][0] > vOrigin[0] )
			{
				vJumpedAt2[0] = vJumpedAt[id][0]+(xDistance*16.03125/fDistance);
				vTraceEnd[0] = vOrigin[0]-(xDistance*16.03125/fDistance);
			}
			else if( vJumpedAt[id][0] < vOrigin[0] )
			{
				vJumpedAt2[0] = vJumpedAt[id][0]-(xDistance*16.03125/fDistance);
				vTraceEnd[0] = vOrigin[0]+(xDistance*16.03125/fDistance);
			}
			else
			{
				vJumpedAt2[0] = vJumpedAt[id][0];
				vTraceEnd[0] = vOrigin[0];
			}
			
			if( vJumpedAt[id][1] > vOrigin[1] )
			{
				vJumpedAt2[1] = vJumpedAt[id][1]+(yDistance*16.03125/fDistance);
				vTraceEnd[1] = vOrigin[1]-(yDistance*16.03125/fDistance);
			}
			else if( vJumpedAt[id][1] < vOrigin[1] )
			{
				vJumpedAt2[1] = vJumpedAt[id][1]-(yDistance*16.03125/fDistance);
				vTraceEnd[1] = vOrigin[1]+(yDistance*16.03125/fDistance);
			}
			else
			{
				vJumpedAt2[1] = vJumpedAt[id][1];
				vTraceEnd[1] = vOrigin[1];
			}
			
			static type;
			
			if( vJumpedAt[id][2] == vOrigin[2]
			&& fDistance > get_cvar_num("kz_min_lj")
			&& fMaxGroundSpeed[id] < 277
			&& cjumped[id] == false
			&& !(fDistance > get_cvar_float("kz_max_lj")) )
			{
				type = INFO_ZERO;
				static Distance, MaxAirSpeed, MaxGroundSpeed, sync;
				if( goodsync[id] > 0 )
					sync = (goodsync[id]*100/(goodsync[id]+badsync[id]));
				else
					sync = INFO_ZERO;
				Distance = floatround((fDistance*1000000), floatround_floor);
				MaxAirSpeed = floatround((fMaxAirSpeed[id]*1000000), floatround_floor);
				MaxGroundSpeed = floatround((fMaxGroundSpeed[id]*1000000), floatround_floor);
				check_maintop(id, Distance, MaxAirSpeed, MaxGroundSpeed, strafes[id], sync, type);
				
				static ljStatsRed, ljStatsGreen, ljStatsBlue, i, kz_ljs_beam, sound;
				ljStatsRed = get_cvar_num("kz_ljstats_red");
				ljStatsGreen = get_cvar_num("kz_ljstats_green");
				ljStatsBlue = get_cvar_num("kz_ljstats_blue");
				kz_ljs_beam = get_cvar_num("kz_ljs_beam");
				sound = get_cvar_num("kz_lj_sounds");
				if( gHasLjStats[id] )
				{
					if( kz_ljs_beam == 1)
					{
						message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
						write_byte (0);
						write_coord(floatround(vJumpedAt2[0]));
						write_coord(floatround(vJumpedAt2[1]));
						write_coord(floatround(vJumpedAt2[2]));
						write_coord(floatround(vTraceEnd[0]));
						write_coord(floatround(vTraceEnd[1]));
						write_coord(floatround(vTraceEnd[2]));
						write_short(gBeam);
						write_byte(1);
						write_byte(5);
						write_byte(30);
						write_byte(20);
						write_byte(0);
						write_byte(random_num(32, 255));
						write_byte(random_num(32, 255));
						write_byte(random_num(32, 255));
						write_byte(200);
						write_byte(200);
						message_end();
					}
					else if( kz_ljs_beam == 2)
					{
						set_task(1.0,"gocheck", id);
						set_task(1.5,"gocheck", id);
						set_task(2.0,"gocheck", id);
						set_task(2.5,"gocheck", id);
						for( i = INFO_ZERO; i < 127; i++ )
						{
							if( i == 0 )
							{
								message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
								write_byte (0);
								write_coord(floatround(vJumpedAt2[0]));
								write_coord(floatround(vJumpedAt2[1]));
								write_coord(floatround(vTraceEnd[2]));
								write_coord(floatround(vBeamPos[id][0][0]));
								write_coord(floatround(vBeamPos[id][0][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_short(gBeam);
								write_byte(1);
								write_byte(5);
								write_byte(30);
								write_byte(20);
								write_byte(0);
								write_byte(255);
								write_byte(255);
								write_byte(0);
								write_byte(200);
								write_byte(200);
								message_end();
								
								message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
								write_byte (0);
								write_coord(floatround(vBeamPos[id][0][0]));
								write_coord(floatround(vBeamPos[id][0][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_coord(floatround(vBeamPos[id][1][0]));
								write_coord(floatround(vBeamPos[id][1][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_short(gBeam);
								write_byte(1);
								write_byte(5);
								write_byte(30);
								write_byte(20);
								write_byte(0);
								write_byte(255);
								write_byte(255);
								write_byte(0);
								write_byte(200);
								write_byte(200);
								message_end();
							}
							else if( i == 127 || (vBeamPos[id][i+1][0] == 0
							&& vBeamPos[id][i+1][1] == 0
							&& vBeamPos[id][i+1][2] == 0) )
							{
								message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
								write_byte (0);
								write_coord(floatround(vBeamPos[id][i][0]));
								write_coord(floatround(vBeamPos[id][i][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_coord(floatround(vOrigin[0]));
								write_coord(floatround(vOrigin[1]));
								write_coord(floatround(vTraceEnd[2]));
								write_short(gBeam);
								write_byte(1);
								write_byte(5);
								write_byte(30);
								write_byte(20);
								write_byte(0);
								if( vBeamPosStatus[id][i] == 1 )
								{
									write_byte(255);
									write_byte(0);
									write_byte(0);
								}
								else
								{
									write_byte(255);
									write_byte(255);
									write_byte(0);
								}
								write_byte(200);
								write_byte(200);
								message_end();
								
								message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
								write_byte (0);
								write_coord(floatround(vOrigin[0]));
								write_coord(floatround(vOrigin[1]));
								write_coord(floatround(vTraceEnd[2]));
								write_coord(floatround(vTraceEnd[0]));
								write_coord(floatround(vTraceEnd[1]));
								write_coord(floatround(vTraceEnd[2]));
								write_short(gBeam);
								write_byte(1);
								write_byte(5);
								write_byte(30);
								write_byte(20);
								write_byte(0);
								if( vBeamPosStatus[id][i] == 1 )
								{
									write_byte(255);
									write_byte(0);
									write_byte(0);
								}
								else
								{
									write_byte(255);
									write_byte(255);
									write_byte(0);
								}
								write_byte(200);
								write_byte(200);
								message_end();
								i=127;
							}
							else
							{
								message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
								write_byte (0);
								write_coord(floatround(vBeamPos[id][i][0]));
								write_coord(floatround(vBeamPos[id][i][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_coord(floatround(vBeamPos[id][i+1][0]));
								write_coord(floatround(vBeamPos[id][i+1][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_short(gBeam);
								write_byte(1);
								write_byte(5);
								write_byte(30);
								write_byte(20);
								write_byte(0);
								if( vBeamPosStatus[id][i] == 1 )
								{
									write_byte(255);
									write_byte(0);
									write_byte(0);
								}
								else
								{
									write_byte(255);
									write_byte(255);
									write_byte(0);
								}
								write_byte(200);
								write_byte(200);
								message_end();
							}
						}
					}
				}
				
				set_hudmessage(ljStatsRed, ljStatsGreen, ljStatsBlue, -1.0, 0.70, 0, 0.0, 2.0, 0.1, 0.1, 3);
				idist = floatround(fDistance, floatround_floor);
				static strdist[128];
				num_to_word(idist, strdist, 127);
				for( i = INFO_ONE; 0 < i <= MAXPLAYERS; i++ )
				{
					if( (i == id || is_user_spectating_player(i, id)) && gHasLjStats[i] )
					{
						show_hudmessage(i, "Distance: %f^nMaxSpeed: %f^nPreStrafe: %f^nStrafes: %d^nSync: %d", fDistance, fMaxAirSpeed[id], fMaxGroundSpeed[id], strafes[id], sync );
						
						client_print(i, print_console, "Distance: %f MaxSpeed: %f PreStrafe: %f Strafes: %d Sync: %d", fDistance, fMaxAirSpeed[id], fMaxGroundSpeed[id], strafes[id], sync );
						
						if( sound == 2 && gHasColorChat[i] )
							client_cmd(i, "speak ^"vox/%s uniform(e30) it south(e15)^"", strdist);
						
						if( i != id && (kz_ljs_beam == 1 || kz_ljs_beam == 2) )
						{
							message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, i);
							write_byte (0);
							write_coord(floatround(vJumpedAt2[0]));
							write_coord(floatround(vJumpedAt2[1]));
							write_coord(floatround(vJumpedAt2[2]));
							write_coord(floatround(vTraceEnd[0]));
							write_coord(floatround(vTraceEnd[1]));
							write_coord(floatround(vTraceEnd[2]));
							write_short(gBeam);
							write_byte(1);
							write_byte(5);
							write_byte(30);
							write_byte(20);
							write_byte(0);
							write_byte(random_num(32, 255));
							write_byte(random_num(32, 255));
							write_byte(random_num(32, 255));
							write_byte(200);
							write_byte(200);
							message_end();
						}
					}
				}
				
				static Float:max_lj, Float:leet_lj, Float:pro_lj, Float:good_lj, ljtop;
				max_lj = get_cvar_float("kz_max_lj");
				leet_lj = get_cvar_float("kz_leet_lj");
				pro_lj = get_cvar_float("kz_pro_lj");
				good_lj = get_cvar_float("kz_good_lj");
				ljtop = get_cvar_num("kz_lj_top");
				if( fDistance < max_lj
				&& !(fDistance < leet_lj)
				&& !(0 > leet_lj)
				&& (ljtop == 1
				|| ljtop == 3) )
				{
					static color, name[33];
					color = get_cvar_num("kz_leet_lj_clr");
					get_user_name(id, name, 31);
					for( i = INFO_ONE; 0 < i <= MAXPLAYERS; i++ )
					{
						if( i == id || is_user_spectating_player(i, id) || (pev_valid(i) && is_user_connected(i) && gHasColorChat[i]) )
						{
							if( color < 6 && color > 0 )
							{
								switch(color)
								{
									case 1: ColorChat(i, RED, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 2: ColorChat(i, GREEN, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 3: ColorChat(i, BLUE, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 4: ColorChat(i, GREY, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 5: ColorChat(i, TEAM_COLOR, "[XJ] %s jumped %.3f units!", name, fDistance);
								}
							}
							else
								client_print(i, print_chat, "[XJ] %s jumped %.3f units!", name, fDistance);
							
							if( sound == 1 )
							{
								if( i == id || is_user_spectating_player(i, id) )
									client_cmd(i, "speak misc/mod_wickedsick");
								else
									client_cmd(i, "speak misc/mod_godlike");
							}
						}
					}
				}
				
				else if( fDistance < max_lj
				&& !(fDistance < pro_lj)
				&& !(0 > pro_lj)
				&& (ljtop == 1
				|| ljtop == 3) )
				{
					static color, name[33];
					color = get_cvar_num("kz_pro_lj_clr");
					get_user_name(id, name, 31);
					for( i = INFO_ONE; 0 < i <= MAXPLAYERS; i++ )
					{
						if( i == id || is_user_spectating_player(i, id) || (pev_valid(i) && is_user_connected(i) && gHasColorChat[i]) )
						{
							if( color < 6 && color > 0 )
							{
								switch(color)
								{
									case 1: ColorChat(i, RED, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 2: ColorChat(i, GREEN, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 3: ColorChat(i, BLUE, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 4: ColorChat(i, GREY, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 5: ColorChat(i, TEAM_COLOR, "[XJ] %s jumped %.3f units!", name, fDistance);
								}
							}
							else
								client_print(i, print_chat, "[XJ] %s jumped %.3f units!", name, fDistance);
						}
						if( (i == id || is_user_spectating_player(i, id)) && sound == 1 )
							client_cmd(i, "speak misc/perfect");
					}
				}
				
				else if( fDistance < max_lj
				&& !(fDistance < good_lj)
				&& !(0 > good_lj)
				&& (ljtop == 1
				|| ljtop == 3) )
				{
					static color, name[33];
					color = get_cvar_num("kz_good_lj_clr");
					get_user_name(id, name, 31);
					for( i = INFO_ONE; 0 < i <= MAXPLAYERS; i++ )
					{
						if( i == id || is_user_spectating_player(i, id) || (pev_valid(i) && is_user_connected(i) && gHasColorChat[i]) )
						{
							if( color < 6 && color > 0 )
							{
								switch(color)
								{
									case 1: ColorChat(i, RED, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 2: ColorChat(i, GREEN, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 3: ColorChat(i, BLUE, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 4: ColorChat(i, GREY, "[XJ] %s jumped %.3f units!", name, fDistance);
									case 5: ColorChat(i, TEAM_COLOR, "[XJ] %s jumped %.3f units!", name, fDistance);
								}
							}
							else
								client_print(i, print_chat, "[XJ] %s jumped %.3f units!", name, fDistance);
						}
						if( (i == id || is_user_spectating_player(i, id)) && sound == 1 )
							client_cmd(i, "speak misc/impressive");
					}
				}
			}
			else if( vJumpedAt[id][2] == vOrigin[2]
			&& fDistance > get_cvar_num("kz_min_lj")
			&& fMaxGroundSpeed[id] < 287
			&& cjumped[id] == true
			&& !(fDistance > (get_cvar_float("kz_max_lj") + get_cvar_num("kz_cj_dif"))) )
			{
				type = INFO_ONE;
				static Distance, MaxAirSpeed, MaxGroundSpeed, sync;
				if( goodsync[id] > 0 )
					sync = (goodsync[id]*100/(goodsync[id]+badsync[id]));
				else
					sync = INFO_ZERO;
				Distance = floatround((fDistance*1000000), floatround_floor);
				MaxAirSpeed = floatround((fMaxAirSpeed[id]*1000000), floatround_floor);
				MaxGroundSpeed = floatround((fMaxGroundSpeed[id]*1000000), floatround_floor);
				check_maintop(id, Distance, MaxAirSpeed, MaxGroundSpeed, strafes[id], sync, type);
				
				static ljStatsRed, ljStatsGreen, ljStatsBlue, i, kz_ljs_beam, sound;
				ljStatsRed = get_cvar_num("kz_ljstats_red");
				ljStatsGreen = get_cvar_num("kz_ljstats_green");
				ljStatsBlue = get_cvar_num("kz_ljstats_blue");
				kz_ljs_beam = get_cvar_num("kz_ljs_beam");
				sound = get_cvar_num("kz_lj_sounds");
				if( gHasLjStats[id] )
				{
					if( kz_ljs_beam == 1)
					{
						message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
						write_byte (0);
						write_coord(floatround(vJumpedAt2[0]));
						write_coord(floatround(vJumpedAt2[1]));
						write_coord(floatround(vJumpedAt2[2]));
						write_coord(floatround(vTraceEnd[0]));
						write_coord(floatround(vTraceEnd[1]));
						write_coord(floatround(vTraceEnd[2]));
						write_short(gBeam);
						write_byte(1);
						write_byte(5);
						write_byte(30);
						write_byte(20);
						write_byte(0);
						write_byte(random_num(32, 255));
						write_byte(random_num(32, 255));
						write_byte(random_num(32, 255));
						write_byte(200);
						write_byte(200);
						message_end();
					}
					else if( kz_ljs_beam == 2)
					{
						set_task(1.0,"gocheck", id);
						set_task(1.5,"gocheck", id);
						set_task(2.0,"gocheck", id);
						set_task(2.5,"gocheck", id);
						for( i = INFO_ZERO; i < 127; i++ )
						{
							if( i == 0 )
							{
								message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
								write_byte (0);
								write_coord(floatround(vDuckedAt[id][0]));
								write_coord(floatround(vDuckedAt[id][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_coord(floatround(vBeamPos[id][0][0]));
								write_coord(floatround(vBeamPos[id][0][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_short(gBeam);
								write_byte(1);
								write_byte(5);
								write_byte(30);
								write_byte(20);
								write_byte(0);
								write_byte(0);
								write_byte(255);
								write_byte(0);
								write_byte(200);
								write_byte(200);
								message_end();
								
								message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
								write_byte (0);
								write_coord(floatround(vBeamPos[id][0][0]));
								write_coord(floatround(vBeamPos[id][0][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_coord(floatround(vBeamPos[id][1][0]));
								write_coord(floatround(vBeamPos[id][1][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_short(gBeam);
								write_byte(1);
								write_byte(5);
								write_byte(30);
								write_byte(20);
								write_byte(0);
								write_byte(0);
								write_byte(255);
								write_byte(0);
								write_byte(200);
								write_byte(200);
								message_end();
							}
							else if( i == 127 || (vBeamPos[id][i+1][0] == 0
							&& vBeamPos[id][i+1][1] == 0
							&& vBeamPos[id][i+1][2] == 0) )
							{
								message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
								write_byte (0);
								write_coord(floatround(vBeamPos[id][i][0]));
								write_coord(floatround(vBeamPos[id][i][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_coord(floatround(vOrigin[0]));
								write_coord(floatround(vOrigin[1]));
								write_coord(floatround(vTraceEnd[2]));
								write_short(gBeam);
								write_byte(1);
								write_byte(5);
								write_byte(30);
								write_byte(20);
								write_byte(0);
								if( vBeamPosStatus[id][i] == 1 )
								{
									write_byte(255);
									write_byte(0);
									write_byte(0);
								}
								else
								{
									write_byte(255);
									write_byte(255);
									write_byte(0);
								}
								write_byte(200);
								write_byte(200);
								message_end();
								
								message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
								write_byte (0);
								write_coord(floatround(vOrigin[0]));
								write_coord(floatround(vOrigin[1]));
								write_coord(floatround(vTraceEnd[2]));
								write_coord(floatround(vTraceEnd[0]));
								write_coord(floatround(vTraceEnd[1]));
								write_coord(floatround(vTraceEnd[2]));
								write_short(gBeam);
								write_byte(1);
								write_byte(5);
								write_byte(30);
								write_byte(20);
								write_byte(0);
								if( vBeamPosStatus[id][i] == 1 )
								{
									write_byte(255);
									write_byte(0);
									write_byte(0);
								}
								else
								{
									write_byte(255);
									write_byte(255);
									write_byte(0);
								}
								write_byte(200);
								write_byte(200);
								message_end();
								i=127;
							}
							else
							{
								message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, id);
								write_byte (0);
								write_coord(floatround(vBeamPos[id][i][0]));
								write_coord(floatround(vBeamPos[id][i][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_coord(floatround(vBeamPos[id][i+1][0]));
								write_coord(floatround(vBeamPos[id][i+1][1]));
								write_coord(floatround(vTraceEnd[2]));
								write_short(gBeam);
								write_byte(1);
								write_byte(5);
								write_byte(30);
								write_byte(20);
								write_byte(0);
								if( vBeamPosStatus[id][i] == 1 )
								{
									write_byte(255);
									write_byte(0);
									write_byte(0);
								}
								else if( vBeamPosStatus[id][i] == -1 )
								{
									write_byte(0);
									write_byte(255);
									write_byte(0);
								}
								else
								{
									write_byte(255);
									write_byte(255);
									write_byte(0);
								}
								write_byte(200);
								write_byte(200);
								message_end();
							}
						}
					}
				}
				
				set_hudmessage(ljStatsRed, ljStatsGreen, ljStatsBlue, -1.0, 0.70, 0, 0.0, 2.0, 0.1, 0.1, 3);
				idist = floatround(fDistance, floatround_floor);
				static strdist[128];
				num_to_word(idist, strdist, 127);
				for( i = INFO_ONE; 0 < i <= MAXPLAYERS; i++ )
				{
					if( (i == id || is_user_spectating_player(i, id)) && gHasLjStats[i] )
					{
						show_hudmessage(i, "Distance: %f^nMaxSpeed: %f^nPreStrafe: %f^nStrafes: %d^nSync: %d", fDistance, fMaxAirSpeed[id], fMaxGroundSpeed[id], strafes[id], sync );
						
						client_print(i, print_console, "Distance: %f MaxSpeed: %f PreStrafe: %f Strafes: %d Sync: %d", fDistance, fMaxAirSpeed[id], fMaxGroundSpeed[id], strafes[id], sync );
						
						if( sound == 2 && gHasColorChat[i] )
							client_cmd(i, "speak ^"vox/%s uniform(e30) it south(e15)^"", strdist);
						
						if( i != id && (kz_ljs_beam == 1 || kz_ljs_beam == 2) )
						{
							message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0, 0, 0}, i);
							write_byte (0);
							write_coord(floatround(vJumpedAt2[0]));
							write_coord(floatround(vJumpedAt2[1]));
							write_coord(floatround(vJumpedAt2[2]));
							write_coord(floatround(vTraceEnd[0]));
							write_coord(floatround(vTraceEnd[1]));
							write_coord(floatround(vTraceEnd[2]));
							write_short(gBeam);
							write_byte(1);
							write_byte(5);
							write_byte(30);
							write_byte(20);
							write_byte(0);
							write_byte(random_num(32, 255));
							write_byte(random_num(32, 255));
							write_byte(random_num(32, 255));
							write_byte(200);
							write_byte(200);
							message_end();
						}
					}
				}
				
				static Float:cj_dif, Float:max_cj, Float:leet_cj, Float:pro_cj, Float:good_cj, ljtop;
				cj_dif = get_cvar_float("kz_cj_dif");
				max_cj = get_cvar_float("kz_max_lj") + cj_dif;
				leet_cj = get_cvar_float("kz_leet_lj") + cj_dif;
				pro_cj = get_cvar_float("kz_pro_lj") + cj_dif;
				good_cj = get_cvar_float("kz_good_lj") + cj_dif;
				ljtop = get_cvar_num("kz_lj_top");
				if( fDistance < max_cj
				&& !(fDistance < leet_cj)
				&& !(cj_dif > leet_cj)
				&& (ljtop == 1
				|| ljtop == 3) )
				{
					static color, name[33];
					color = get_cvar_num("kz_leet_cj_clr");
					get_user_name(id, name, 31);
					for( i = INFO_ONE; 0 < i <= MAXPLAYERS; i++ )
					{
						if( i == id || is_user_spectating_player(i, id) || (pev_valid(i) && is_user_connected(i) && gHasColorChat[i]) )
						{
							if( color < 6 && color > 0 )
							{
								switch(color)
								{
									case 1: ColorChat(i, RED, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 2: ColorChat(i, GREEN, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 3: ColorChat(i, BLUE, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 4: ColorChat(i, GREY, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 5: ColorChat(i, TEAM_COLOR, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
								}
							}
							else
								client_print(i, print_chat, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
							
							if( sound == 1 )
							{
								if( i == id || is_user_spectating_player(i, id) )
									client_cmd(i, "speak misc/mod_wickedsick");
								else
									client_cmd(i, "speak misc/mod_godlike");
							}
						}
					}
				}
				
				else if( fDistance < max_cj
				&& !(fDistance < pro_cj)
				&& !(cj_dif > pro_cj)
				&& (ljtop == 1
				|| ljtop == 3) )
				{
					static color, name[33];
					color = get_cvar_num("kz_pro_cj_clr");
					get_user_name(id, name, 31);
					for( i = INFO_ONE; 0 < i <= MAXPLAYERS; i++ )
					{
						if( i == id || is_user_spectating_player(i, id) || (pev_valid(i) && is_user_connected(i) && gHasColorChat[i]) )
						{
							if( color < 6 && color > 0 )
							{
								switch(color)
								{
									case 1: ColorChat(i, RED, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 2: ColorChat(i, GREEN, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 3: ColorChat(i, BLUE, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 4: ColorChat(i, GREY, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 5: ColorChat(i, TEAM_COLOR, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
								}
							}
							else
								client_print(i, print_chat, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
						}
						if( (i == id || is_user_spectating_player(i, id)) && sound == 1 )
							client_cmd(i, "speak misc/perfect");
					}
				}
				
				else if( fDistance < max_cj
				&& !(fDistance < good_cj)
				&& !(cj_dif > good_cj)
				&& (ljtop == 1
				|| ljtop == 3) )
				{
					static color, name[33];
					color = get_cvar_num("kz_good_cj_clr");
					get_user_name(id, name, 31);
					for( i = INFO_ONE; 0 < i <= MAXPLAYERS; i++ )
					{
						if( i == id || is_user_spectating_player(i, id) || (pev_valid(i) && is_user_connected(i) && gHasColorChat[i]) )
						{
							if( color < 6 && color > 0 )
							{
								switch(color)
								{
									case 1: ColorChat(i, RED, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 2: ColorChat(i, GREEN, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 3: ColorChat(i, BLUE, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 4: ColorChat(i, GREY, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
									case 5: ColorChat(i, TEAM_COLOR, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
								}
							}
							else
								client_print(i, print_chat, "[XJ] %s jumped %.3f units with cj!", name, fDistance);
						}
						if( (i == id || is_user_spectating_player(i, id)) && sound == 1 )
							client_cmd(i, "speak misc/impressive");
					}
				}
			}
			fMaxAirSpeed[id] = 0.0;
			fMaxGroundSpeed[id] = 0.0;
			cjumped[id] = false;
			gInAir[id] = false;
		}
		else if( flags&FL_ONGROUND
		&& gInAir[id] == false )
		{
			pev(id, pev_velocity, vVelocity);
			vVelocity[2]-=vVelocity[2];
			if( vector_length(vVelocity) > 277
			&& doubleducked[id] == false )
				set_task(0.5,"gocheck", id);
			gInAir[id] = false;
			fMaxAirSpeed[id] = 0.0;
			fMaxGroundSpeed[id] = 0.0;
			cjumped[id] = false;
		}
		
		static i;
		for( i = INFO_ZERO; i < 127; i++ )
		{
			pev(id, pev_origin, vOrigin);
			
			if( vBeamPos[id][i][0] == 0
			&& vBeamPos[id][i][1] == 0
			&& vBeamPos[id][i][2] == 0 )
			{
				vBeamPos[id][i][0] = vOrigin[0];
				vBeamPos[id][i][1] = vOrigin[1];
				vBeamPos[id][i][2] = vOrigin[2];
				if( doubleducked[id] == true || induck[id] == true )
				{
					vBeamPosStatus[id][i] = vOrigin[0]-vOrigin[0]-1;
				}
				else if( is_in_duck(id) )
					vBeamPosStatus[id][i] = vOrigin[0]-vOrigin[0]+1;
				else
					vBeamPosStatus[id][i] = vOrigin[0]-vOrigin[0];
				i=127;
			}
		}
		
		if( flags&FL_ONGROUND )
		{
			static ClassName[32];
			pev(pev(id, pev_groundentity), pev_classname, ClassName, 32);
			if( equal(ClassName, "func_train") || equal(ClassName, "func_door") || equal(ClassName, "func_door_rotating") )
			{
				gocheck(id);
				set_task(0.4,"gocheck", id);
			}
			if( OnGround[id] == false )
			{
				pev(id, pev_origin, vOrigin);
				if( doubleducked[id] == false
				&& !(cjumped[id] == true
				&& buttons&IN_JUMP
				&& !(oldbuttons&IN_JUMP)) )
					set_task(0.4,"gocheck", id);
				else if( doubleducked[id] == true
				&& !(vOrigin[2] == vDuckedAt[id][2]) )
					set_task(0.5,"gocheck", id);
				OnGround[id] = true;
			}
		}
		if( buttons&IN_DUCK
		&& flags&FL_ONGROUND
		&& gInAir[id] == false )
		{
			if( induck[id] == false )
			{
				cducked[id] = true;
				induck[id] = true;
				set_task(0.1,"testcjstart", id);
				
				pev(id, pev_origin, vOrigin);
				vDuckedAt[id][0] = vOrigin[0];
				vDuckedAt[id][1] = vOrigin[1];
				vDuckedAt[id][2] = vOrigin[2];
				
				static i;
				for( i = INFO_ZERO; i < 128; i++ )
				{
					vBeamPos[id][i][0] = vOrigin[0]-vOrigin[0];
					vBeamPos[id][i][1] = vOrigin[1]-vOrigin[1];
					vBeamPos[id][i][2] = vOrigin[2]-vOrigin[2];
				}
			}
		}
		else if( oldbuttons&IN_DUCK )
		{
			induck[id] = false;
			if( cducked[id] == true && !is_in_duck(id) )
			{
				set_task(0.3,"ddend", id);
				doubleducked[id] = true;
				cducked[id] = false;
			}
		}
		if( !(flags&FL_ONGROUND) )
			OnGround[id] = false;
	}
	return FMRES_IGNORED;
}

public fwdPlayerPostThink(id)
{
	if( is_user_alive(id) && get_cvar_num("kz_ljs_enabled") )
	{
		static buttons;
		buttons = pev(id, pev_button);
		
		pev(id, pev_angles, angle);
		if( old_angle1[id] > angle[1] )
		{
			turning_left[id] = false;
			turning_right[id] = true;
		}
		else if( old_angle1[id] < angle[1] )
		{
			turning_left[id] = true;
			turning_right[id] = false;
		}
		else
		{
			turning_left[id] = false;
			turning_right[id] = false;
		}
		if( straifing_aw[id] == false
		&& (buttons&IN_MOVELEFT
		|| buttons&IN_FORWARD)
		&& (turning_left[id] == true
		|| turning_right[id] == true )
		&& !(buttons&IN_MOVERIGHT
		|| buttons&IN_BACK) )
		{
			straifing_aw[id] = true;
			straifing_sd[id] = false;
			strafes[id] += INFO_ONE;
		}
		else if( straifing_sd[id] == false
		&& (buttons&IN_MOVERIGHT
		|| buttons&IN_BACK)
		&& (turning_left[id] == true
		|| turning_right[id] == true )
		&& !(buttons&IN_MOVELEFT
		|| buttons&IN_FORWARD) )
		{
			straifing_aw[id] = false;
			straifing_sd[id] = true;
			strafes[id] += INFO_ONE;
		}
		if( pev(id, pev_flags)&FL_ONGROUND
		&& (gInAir[id] == true
		|| OnGround[id] == false) )
			fwdPlayerPreThink(id);
	}
}

public fwdTouch(ent, id)
{ 
	static ClassName[32];
	if( pev_valid(ent) )
	{
		pev(ent, pev_classname, ClassName, 31);
	}
	static ClassName2[32];
	if( pev_valid(id) )
	{
		pev(id, pev_classname, ClassName2, 31);
	}
	if( equal(ClassName2, "player") )
	{
		if( equal(ClassName, "trigger_teleport") || equal(ClassName, "trigger_push") || equal(ClassName, "func_train") || equal(ClassName, "func_door") || equal(ClassName, "func_door_rotating") )
		{
			gocheck(id);
			set_task(0.4,"gocheck", id);
		}
	}
}

get_spectated_player(spectator)
{
	static player;
	
	if( !pev_valid(spectator) || !pev_valid(player) )
		return 0;
	if( !is_user_connected(spectator) || !is_user_connected(player) )
		return 0;
	if( is_user_alive(spectator) || !is_user_alive(player) )
		return 0;
	if( pev(spectator, pev_deadflag) != 2 )
		return 0;
	
	player = pev(spectator, pev_iuser2);
	
	static specmode;
	specmode = pev(spectator, pev_iuser1);
	if( specmode == 1 || specmode == 2 || specmode == 4 )
		return player;
	return 0;
}

is_user_spectating_player(spectator, player)
{
	if( !pev_valid(spectator) || !pev_valid(player) )
		return 0;
	if( !is_user_connected(spectator) || !is_user_connected(player) )
		return 0;
	if( is_user_alive(spectator) || !is_user_alive(player) )
		return 0;
	if( pev(spectator, pev_deadflag) != 2 )
		return 0;
	if( pev(spectator, pev_iuser2) != player )
		return 0;
	
	static specmode;
	specmode = pev(spectator, pev_iuser1);
	if( specmode == 1 || specmode == 2 || specmode == 4 )
		return 1;
	return 0;
}

is_in_duck(player)
{
	// supplied with invalid entities
	if( !pev_valid(player)  )
		return 0;
	
	// retrieve absolutes
	static Float:absmin[3], Float:absmax[3];
	
	pev(player, pev_absmin, absmin);
	pev(player, pev_absmax, absmax);
	
	absmin[2]+=64.0;
	
	if( absmin[2] < absmax[2] )
	{
		return 0;
	}
	return 1;
}

Contact
ViewVC Help
Powered by ViewVC 1.0.4