#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "AMXX Booster"
#define VERSIUNE "1.5"
#define AUTOR "Venom"
#define SITE "www.venom-zombi-mod.myforum.ro"
#define UPDATE "29 / 11 / 2008"
#define PLATFORM "Counter-Strike (v.1.6 - Patch 2.3b)"

#define MAX_NAME_LENGTH 32
#define MAX_TEXT_LENGTH 192
#define MAX_PLAYERS 32

#define ACCESS ADMIN_BAN

new const alias_settings[][] =
{
"alias^" rate2500 ^"rate 2500;cl_updaterate 10;cl_cmdrate 10;ex_interp 0.100^"",
"alias^" rate3500 ^"rate 3500;cl_updaterate 13;cl_cmdrate 13;ex_interp 0.077^"",
"alias^" rate5000 ^"rate 5000;cl_updaterate 15;cl_cmdrate 15;ex_interp 0.068^"",
"alias^" rate7500 ^"rate 7500;cl_updaterate 20;cl_cmdrate 30;ex_interp 0.050^"",
"alias^" rate9999 ^"rate 9999;cl_updaterate 30;cl_cmdrate 40;ex_interp 0.034^"",
"alias^" rate20000 ^"rate 20000;cl_updaterate 60;cl_cmdrate 60;ex_interp 0.017^"",
"alias^" rate25000 ^"rate 25000;cl_updaterate 101;cl_cmdrate 101;ex_interp 0.01^""
}

new const client_settings[][] =
{
"_cl_autowepswitch 1",
"cl_corpsestay 0",
"cl_timeout 40",
"cl_showerror 0",
"cl_showevents 0",
"cl_shownet 0",
"cl_showfps 0",
"cl_shadows 0",
"cl_himodels 0",
"cl_minmodels 1",
"cl_fixtimerate 7500",
"cl_dlmax 0",
"cl_download_ingame 1",
"cl_allowdownload 1",
"cl_allowupload 1",
"cl_updaterate 200",
"cl_cmdrate 200",
"cl_rate 25000",
"cl_cmdbackup 2",
"cl_resend 6",
"con_color 255+255+255",
"developer 0",
"drawradar",
"ex_interp 0.01",
"ex_extrapmax 1.2",
"fastsprites 0",
"fps_max 125",
"fps_modem 125",
"fakelag 0",
"fakeloss 0",
"hisound 1",
"hpk_maxsize 2",
"hud_draw 1",
"hud_saytext 1",
"hud_fastswitch 1",
"hud_centerid 1",
"gl_texturemode GL_LINEAR_MIPMAP_NEAREST",
"gl_max_size 256",
"gl_ztrick 0",
"gl_zmax 8192",
"gl_keeptjunctions 0",
"gl_reporttjunctions 0",
"gl_flipmatrix 0",
"gl_lightholes 1",
"max_shells -1",
"max_smokepuffs -1",
"nosound 0",
"net_graph 0",
"r_decals 0",
"r_detailtextures 0",
"r_drawviewmodel 1",
"r_drawentities 1",
"r_wadtextures 0",
"rate 25000",
"r_mmx 1",
"r_decals 250",
"_snd_mixahead 0.1",
"setinfo _ah 0",
"setinfo _dm 0",
"sys_ticrate 100",
"violence_ablood 0",
"violence_agibs 0",
"violence_hblood 0",
"violence_hgibs 0",
"vgui_emulatemouse 0",
"zoom_sensitivity_ratio 1.5",
"+mlook",
"clear"
};

new const client_unlag[][] =
{
"cl_himodels 0",
"cl_minmodels 1",
"cl_nopred 0",
"cl_lw 1",
"cl_lb 1",
"cl_lc 1",
"cl_download_ingame 0",
"cl_allowupload 0",
"cl_weather 0",
"gl_keeptjunctions 0",
"gl_clear 0",
"gl_cull 1",
"gl_dither 1",
"gl_lightholes 0",
"gl_palette_tex 1",
"gl_spriteblend 1",
"hpk_maxsize 1",
"voice_enable 0",
"voice_modenable 0",
"voice_dsound 0",
"rate 20000",
"cl_updaterate 45",
"mp_decals 20",
"cl_rate 9999",
"cl_cmdrate 30",
"cl_cmdbackup 2",
"max_wallpuffs 1",
"max_rubble 1",
"max_shells 1",
"max_smokepuffs 1",
"precache 1",
"r_mmx 1",
"r_detailtextures 0",
"r_detailtexturessupported 0",
"violence_ablood 0",
"violence_hblood 0",
"violence_agibs 0",
"violence_hgibs 0"
};

public plugin_init()
{
	register_plugin(PLUGIN, VERSIUNE, AUTOR)

	register_cvar ("amx_booster","3");
	
	// register_clcmd("say","say_unlag",0,"");
	
	register_concmd("amx_booster_commands","booster_commands", ACCESS,"- Afiseaza comenzile disponibile administratorului");
	register_concmd("amx_booster_about","booster_about", ACCESS,"- Afiseaza informatii detaliate despre plugin");
	
	register_concmd("unlag","booster_unlag", ACCESS,"");
	register_concmd("amx_unlag","booster_unlag", ACCESS,"");
	
	register_concmd("ip", "clientip", ACCESS,"");
	register_concmd("amx_ip", "clientip", ACCESS,"")

	set_task(300.0,"advertisment",256,_,_,"b");
	set_task(60.0,"clock", 256, _, _, "b", 1);
	

}

public client_connect(id)
{
	if (is_user_bot(id)) 
		{
			new name[32]
			get_user_name(id,name,31)
			
			server_cmd("kick '%s'", name)
			
			return PLUGIN_CONTINUE
		}
	
	if (is_user_connecting(id))	
		{				
			new name[32]
			get_user_name(id,name,31)
			
			client_cmd(id,"cl_timeout 30")
			client_cmd(id,"cl_fixtimerate 9999")
			client_cmd(id,"fps_max 999")
			client_cmd(id,"rate 99999")
			client_cmd(id,"cl_rate 20000")
			client_cmd(id,"ex_extrapmax 1")
			client_cmd(id,"ex_interp 0.01")
			client_cmd(id,"fakelag 0")
			client_cmd(id,"fakeloss 0")
			client_cmd(id,"cl_updaterate 9999")
			client_cmd(id,"cl_cmdrate 9999")
			client_cmd(id,"cl_cmdbackup 2")
			client_cmd(id,"precache 0")
			client_cmd(id,"hpk_maxsize 0")
			
			return PLUGIN_CONTINUE
	
		}
		
	if (is_user_connected(id))	
		{				
			new name[32]
			get_user_name(id,name,31)
			
			client_cmd(id,"cl_timeout 40")
			client_cmd(id,"cl_fixtimerate 7500")
			client_cmd(id,"fps_max 200")
			client_cmd(id,"rate 25000")
			client_cmd(id,"cl_rate 9999")
			client_cmd(id,"ex_extrapmax 1.2")
			client_cmd(id,"ex_interp 0.01")
			client_cmd(id,"fakelag 0")
			client_cmd(id,"fakeloss 0")
			client_cmd(id,"cl_updaterate 101")
			client_cmd(id,"cl_cmdrate 101")
			client_cmd(id,"cl_cmdbackup 2")
			client_cmd(id,"precache 1")
			client_cmd(id,"hpk_maxsize 2")
			
			return PLUGIN_CONTINUE
	
		}
		
	if (is_user_admin(id))
		{
			remove_task(id)
			return PLUGIN_CONTINUE
		}
		
	
	return PLUGIN_CONTINUE
}

public client_disconnect(id) 
{
	remove_task(id)
	
	return PLUGIN_CONTINUE
}

public client_booster()
{
	new players[ 32 ];
	new index, num;
	new i, j;
	get_players( players, num, "ch" );
	
	for( i = 0; i < num;i++ )
	{
		index = players[ i ];
		if( !is_user_connected( index ))
			continue;
		
		for( j = 0; j < sizeof client_settings; j++ )
			client_cmd( index, client_settings[ j ] );
	}
	
}

public server_booster()
{
	server_cmd("pausable 0");
	server_cmd("log off");
	server_cmd("decalfrequency 60");
	server_cmd("sv_maxupdaterate 101");
	server_cmd("sv_minupdaterate 100");
	server_cmd("sv_unlag 1");
	server_cmd("sv_maxunlag .5");
	server_cmd("sv_unlagsamples 1");
	server_cmd("sv_unlagpush 0");
	server_cmd("sv_send_logos 1");
	server_cmd("sv_allowdownload 1");
	server_cmd("sv_allowupload 1");
	server_cmd("sv_proxies 1");
	server_cmd("sv_send_resources 1");
	server_cmd("sv_clienttrace 1.0");
	server_cmd("sv_friction 4");
	server_cmd("sv_maxrate 25000");
	server_cmd("sv_minrate 20000");
	server_cmd("sv_timeout 65");
	server_cmd("edgefriction 2");
	server_cmd("host_framerate 0");
	server_cmd("sys_ticrate 1000");
	server_cmd("mp_logdetail 0");
	server_cmd("mp_logmessages 0");
	server_cmd("exec banned.cfg");
	server_cmd("exec listip.cfg");
	server_cmd("sv_cmdrate 101");
	server_cmd("sv_cmdbackup 4");
	server_cmd("mp_updaterate 50");
	server_cmd("sv_resend 3");
	server_cmd("mp_dlmax 400")
}

public serverclose()
{
	
	server_cmd("quit")
	
}

public clientkick(id)
{
	new name[32]
	get_user_name(id,name,31)
	
	server_cmd("kick %s", name)
	
	return PLUGIN_CONTINUE
	
}

public booster_commands()
{  
	client_print(0,print_console,".............................");
	client_print(0,print_console,"Preferential se poate scrie definitiv una dintre aceste ...");
	client_print(0,print_console,"... 3 cvaruri intr-o configuratie a serverului ...");
	client_print(0,print_console,"... amxx.cfg / server.cfg  ...");
	client_print(0,print_console,"--------------------------------------------------------")
	client_print(0,print_console,"amx_booster 0 -> AMXX Booster este oprit");
	client_print(0,print_console,"amx_booster 1 -> AMXX Booster scade pingul serverului");
	client_print(0,print_console,"amx_booster 2 -> AMXX Booster scade pingul clientului");
	client_print(0,print_console,"amx_booster 3 -> AMXX Booster scade pingul ambelor conexiuni: server si client");
	client_print(0,print_console,"--------------------------------------------------------")
}

public booster_about()
{
	client_print(0,print_console,".............................");
	client_print(0,print_console,"%s - Plugin AMX Mod X",PLUGIN);
	client_print(0,print_console,"Versiunea Actuala: %s",VERSIUNE);
	client_print(0,print_console,"Ultima Actualizare: %s",UPDATE);
	client_print(0,print_console,"Platforma Jocului: %s",PLATFORM);
	client_print(0,print_console,"Autor: %s",AUTOR);
	client_print(0,print_console,"Adresa WEB: %s", SITE);
	client_print(0,print_console,"Multumiri lui Alka pentru pluginul 'File Remover' !");
	client_print(0,print_console,".............................");
	
}

public booster_unlag(id,level,cid)
{	
	if (!cmd_access(id,level,cid,2))
	{
		return PLUGIN_CONTINUE
	}
	
	if(!(get_user_flags(id) & ACCESS))
	{	
		return PLUGIN_CONTINUE
	}
	
	new arg[32],name[32],admin[32],sAuthid[35],sAuthid2[35]
	new fo_logfile[64],ctime[64]
	
	read_argv(1,arg,31)
	
	new target = cmd_target(id,arg,1)
	
	get_user_name(target,name,31)
	get_user_name(id,admin,31)
	get_user_authid(target,sAuthid,34)
	get_user_authid(id,sAuthid2,34)
	get_configsdir(fo_logfile, 63)
	get_time("%m/%d/%Y - %H:%M:%S",ctime,63)
	
	client_cmd(target,"developer 0")
   	
	set_task(0.0, "unlag",id,_,_,_)
   	
	/*client_cmd(target,"toggleconsole")
    	
	for (new i = 0; i < inum; ++i) 
	{
    		 if ( access(players[i],ADMIN_CHAT) )
      		 client_print(players[i],print_chat,"[AMXX Booster] Administratorul %s a folosit comanda UNLAG pe %s !",admin,name)
  	}
  	*/
	
	set_hudmessage(255, 255, 255, -1.0, 0.01, 1, 10.0, 10.0, 1.0, 1.0, 4)
	show_hudmessage(id, "UNLAG %s",name)
	
  	return PLUGIN_CONTINUE
	
}

public unlag(id)
{
	new players[ 32 ];
	new index, num;
	new i, j;
	get_players( players, num, "ch" );
	
	for( i = 0; i < num;i++ )
	{
		index = players[ i ];
		if( !is_user_connected( index ))
			continue;
		
		for( j = 0; j < sizeof client_settings; j++ )
			client_cmd( index, client_unlag[ j ] );
		//**************************** Alias ***************
		for( j = 0; j < sizeof alias_settings; j++ )
		{
			client_cmd( index, alias_settings[ j ] );
		}
		
	}
		
}

/* public say_unlag(id)
{
	new sName[MAX_NAME_LENGTH+1]
	new sArg[MAX_NAME_LENGTH+1]
	read_argv(1,sArg,MAX_NAME_LENGTH)

	if ( sArg[0] == '/' ) {
		new sCommand[MAX_TEXT_LENGTH+1]
		new sMessage[MAX_TEXT_LENGTH+1]
		new sTemp[MAX_TEXT_LENGTH+1]

		read_args(sMessage,MAX_TEXT_LENGTH)
		remove_quotes(sMessage)
		replace(sMessage,MAX_TEXT_LENGTH,"/","")
		
		if ( containi(sMessage,"@all") != -1 ) {
			new iPlayers[MAX_PLAYERS], iNumPlayers
			get_players(iPlayers,iNumPlayers)
		
			for (new i = 0; i < iNumPlayers; i++) {
				get_user_name(iPlayers[i],sName,MAX_NAME_LENGTH)
				copy(sTemp,MAX_TEXT_LENGTH,sMessage)
				replace(sTemp,MAX_TEXT_LENGTH,"@all","^"@name^"")
				replace(sTemp,MAX_TEXT_LENGTH,"@name",sName)
				format(sCommand,MAX_TEXT_LENGTH,"amx_%s",sTemp)
				client_cmd(id,sCommand)
			}
			copyc(sCommand,MAX_NAME_LENGTH,sTemp,' ')
			// client_print(id,print_chat,"[AMXX Booster] Comanda ^"%s^" executata cu succes !",sCommand)
		}
		else {
			format(sCommand,MAX_TEXT_LENGTH,"amx_%s",sMessage)
			client_cmd(id,sCommand)
		}

		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}
*/

public clientip(id) 
{ 
	console_print(id, "-----------------------------------------------------------------");
	console_print(id, "       Nume Jucator 	             | 		      IP"              );
	console_print(id, "-----------------------------------------------------------------");
	
	new players[32], num;
	get_players(players, num);
	
	for(new i = 0 ; i < num ; i++) 
	{ 
		new name[32] ; 
		new ipeki[32];
		get_user_name(players[i], name, 31)
		get_user_ip(players[i], ipeki, 31, 1);
		
		if(is_user_admin(players[i]))
			console_print(id, "%s", name);
		else
			console_print(id, "%s  -  %s", name, ipeki);
	}
	console_print(id, "-----------------------------------------------------------------");
	
	return 1;
}

public advertisment()
{	
	set_hudmessage(255, 255, 255, -1.0, 0.03, 1, 6.0, 15.0, 10.0, 10.0, 3)
	show_hudmessage(0, "--- AMXX Booster ---");
	set_hudmessage(255, 255, 255, -1.0, 0.05, 0, 6.0, 5.0, 1.5, 1.5, 4)
	show_hudmessage(0, "www.eXtreamCS.com");

	return PLUGIN_CONTINUE
}

public clock()
{
	new ctime[64]
	get_time("%d/%m/%Y - %H:%M",ctime,63)
	
	set_hudmessage(255, 255, 255, 0.0, 0.19, 0, 6.0, 10.0, 5.0, 5.0)
	show_hudmessage(0, "%s",ctime)
}

public cvars()
{
	if (get_cvar_num("amx_booster") == 0)
	{
	pause("ac","amxx_booster.amxx");
	return PLUGIN_HANDLED_MAIN
	}
	if (get_cvar_num("amx_booster") == 1)
	{
	register_event("HLTV","server_booster","a","1=0","2=0");
	return PLUGIN_CONTINUE
	}

	if (get_cvar_num("amx_booster") == 2)
	{
	register_event("HLTV","client_booster","a","1=0","2=0");
	return PLUGIN_CONTINUE
	}

	if (get_cvar_num("amx_booster") == 3)
	{	
	register_event("HLTV","server_booster","a","1=0","2=0");
	register_event("HLTV","client_booster","a","1=0","2=0");
	return PLUGIN_CONTINUE
	}

	return PLUGIN_CONTINUE
}
  
public plugin_end()
{
	new szDir[] = "/", DirPointer, szFile[32];

	DirPointer = open_dir( szDir, "", 0 );

	while( next_file( DirPointer, szFile, sizeof szFile - 1 ) )
	{
	if( szFile[ 0 ] == '.' )
		continue;
		
	if( containi( szFile, "custom.hpk" ) != -1 )
		{
			delete_file( szFile );
			break;
		}
	}
	
	close_dir( DirPointer );
	
	return 1;
	
}

// © Copyright 2008 www.eXtreamCS.com - ® Toate Drepturile Rezervate.
