init(l) {
	level.shaders = strTok("ui_host;line_vertical;nightvision_overlay_goggles;hud_arrow_right",";");
	for(i=0;i<level.shaders.size;i++)
		precacheShader(level.shaders[i]);
	level.regmenuoption["name"] = [];	
	level.fx["dust"] = loadFx( "props/crateexp_dust" );
	level.busy=false;
	level.disco=false;
	level.fx["bombexplosion"] = loadfx( "explosions/tanker_explosion" );
	level.dist = loadfx( "fire/tank_fire_engine" );
	//------------------Menu options-------------------
	//         Displayname    function
	addRegSubMenu("^1Player ^7Options","derp");	
		addRegMenuOption("Toggle Laser","derp",plugins\reg::laser);
		addRegMenuOption("Toggle Promod","derp",plugins\reg::promod);
		addRegMenuOption("Get Some ^3XP","derp",plugins\reg::givexp);	
	addRegSubMenu("^1Choose ^7FPS","fps");
	    addRegMenuOption("^7Use 125 ^3FPS","fps",plugins\reg::fps125);
		addRegMenuOption("^7Use 250 ^3FPS","fps",plugins\reg::fps250);
		addRegMenuOption("^7Use 333 ^3FPS","fps",plugins\reg::fps333);
	addRegSubMenu("^1Activator ^7responses","amsg");
		addRegMenuOption("^1Free For Fast!","amsg",plugins\reg::fff);
		addRegMenuOption("^1Free For Bounce!","amsg",plugins\reg::ffb);
		addRegMenuOption("^1Free For Snipe!","amsg",plugins\reg::ffs);
		addRegMenuOption("^1Free For Knife!","amsg",plugins\reg::knife);
	addRegSubMenu("^1Message ^7Menu","msg");
		addRegMenuOption("Bunnyhop","msg",plugins\reg::bh);
		addRegMenuOption("Website","msg",plugins\reg::site);
		addRegMenuOption("Player^7Menu","msg",plugins\reg::pm);
		addRegMenuOption("Credits","msg",plugins\reg::credits);		
		addRegMenuOption("Only For Pro!!","msg",plugins\reg::random);	
	
	//-------------------------------------------------
	thread onPlayerConnected();
}
onPlayerConnected() {
for(;;) {
		level waittill("connected",player);
			player braxi\_common::clientCmd("bind P openscriptmenu z regmenu");
			player thread OnMenuResponse();
		}
}

OnMenuResponse() {
	self endon("disconnect");
	self.inregmenu = false;
	for(;;wait .05) {
		self waittill("menuresponse", menu, response);
		if(!self.inregmenu && response == "regmenu") {
			self.inregmenu = true;
			for(;self.sessionstate == "playing" && !self isOnGround();wait .05){}
			self thread RegMenu();
			self disableWeapons();
			self freezeControls(true);			
			self allowSpectateTeam( "allies", false );
			self allowSpectateTeam( "axis", false );
			self allowSpectateTeam( "none", false );			
		}
		else if(self.inregmenu && response == "regmenu") self endMenu();	
	}
}
endMenu() {
	self notify("close_reg_menu");
	for(i=0;i<self.regmenu.size;i++) self.regmenu[i] thread FadeOut(1,true,"right");
	self thread Blur(2,0);
	self.regmenubg thread FadeOut(1);
	self.inregmenu = false;
	self enableWeapons();
	self freezeControls(false);
	self allowSpectateTeam( "allies", true );
	self allowSpectateTeam( "axis", true );
	self allowSpectateTeam( "none", true );
}
addRegMenuOption(name,menu,script) {
	if(!isDefined(level.regmenuoption["name"][menu])) level.regmenuoption["name"][menu] = [];
	level.regmenuoption["name"][menu][level.regmenuoption["name"][menu].size] = name;
	level.regmenuoption["script"][menu][level.regmenuoption["name"][menu].size] = script;
}
addRegSubMenu(displayname,name) {
	addRegMenuOption(displayname,"main",name);
}
GetMenuStuct(menu) {
	itemlist = "";
	for(i=0;i<level.regmenuoption["name"][menu].size;i++) itemlist = itemlist + level.regmenuoption["name"][menu][i] + "\n";
	return itemlist;
}
RegMenu() {
	self endon("close_reg_menu");
	self endon("disconnect");
	self thread Blur(0,2);
	submenu = "main";
	self.regmenu[0] = addTextHud( self, -200, 0, .6, "left", "top", "right",0, 101 );	
	self.regmenu[0] setShader("nightvision_overlay_goggles", 400, 650);
	self.regmenu[0] thread FadeIn(.5,true,"right");
	self.regmenu[1] = addTextHud( self, -200, 0, .5, "left", "top", "right", 0, 101 );	
	self.regmenu[1] setShader("black", 400, 650);	
	self.regmenu[1] thread FadeIn(.5,true,"right");
	self.regmenu[2] = addTextHud( self, -200, 89, .5, "left", "top", "right", 0, 102 );		
	self.regmenu[2] setShader("line_vertical", 600, 22);
	self.regmenu[2] thread FadeIn(.5,true,"right");	
	self.regmenu[3] = addTextHud( self, -190, 93, 1, "left", "top", "right", 0, 104 );		
	self.regmenu[3] setShader("ui_host", 14, 14);			
	self.regmenu[3] thread FadeIn(.5,true,"right");
	self.regmenu[4] = addTextHud( self, -165, 100, 1, "left", "middle", "right", 1.4, 103 );
	self.regmenu[4] settext(GetMenuStuct(submenu));
	self.regmenu[4] thread FadeIn(.5,true,"right");
	self.regmenu[5] = addTextHud( self, -170, 400, 1, "left", "middle", "right" ,1.4, 103 );
	self.regmenu[5] settext("^7Select: ^3[Right or Left Mouse]^7\nUse: ^3[[{+activate}]]^7\nLeave: ^3[[{+melee}]]^7\n ^3XP ^1Deathrun");	
	self.regmenu[5] thread FadeIn(.5,true,"right");
	self.regmenubg = addTextHud( self, 0, 0, .5, "left", "top", undefined , 0, 101 );	
	self.regmenubg.horzAlign = "fullscreen";
	self.regmenubg.vertAlign = "fullscreen";
	self.regmenubg setShader("black", 640, 480);
	self.regmenubg thread FadeIn(.2);
	for(selected=0;!self meleebuttonpressed();wait .05) {
		if(self Attackbuttonpressed()) {
			self playLocalSound( "mouse_over" );
			if(selected == level.regmenuoption["name"][submenu].size-1) selected = 0;
			else selected++;	
		}
		if(self adsbuttonpressed()) {
			self braxi\_common::clientCmd("-speed_throw");
			self playLocalSound( "mouse_over" );
			if(selected == 0) selected = level.regmenuoption["name"][submenu].size-1;
			else selected--;
		}
		if(self adsbuttonpressed() || self Attackbuttonpressed()) {
			if(submenu == "main") {
				self.regmenu[2] moveOverTime( .05 );
				self.regmenu[2].y = 89 + (16.8 * selected);	
				self.regmenu[3] moveOverTime( .05 );
				self.regmenu[3].y = 93 + (16.8 * selected);	
			}
			else {
				self.regmenu[7] moveOverTime( .05 );
				self.regmenu[7].y = 10 + self.regmenu[6].y + (16.8 * selected);	
			}
		}
		if((self adsbuttonpressed() || self Attackbuttonpressed()) && !self useButtonPressed()) wait .15;
		if(self useButtonPressed()) {
			if(!isString(level.regmenuoption["script"][submenu][selected+1])) {
				self thread [[level.regmenuoption["script"][submenu][selected+1]]]();
				self thread endMenu();
				self notify("close_reg_menu");
			}
			else {
				abstand = (16.8 * selected);
				submenu = level.regmenuoption["script"][submenu][selected+1];
				self.regmenu[6] = addTextHud( self, -430, abstand + 50, .5, "left", "top", "right", 0, 101 );	
				self.regmenu[6] setShader("black", 200, 300);	
				self.regmenu[6] thread FadeIn(.5,true,"left");
				self.regmenu[7] = addTextHud( self, -430, abstand + 60, .5, "left", "top", "right", 0, 102 );		
				self.regmenu[7] setShader("line_vertical", 200, 22);
				self.regmenu[7] thread FadeIn(.5,true,"left");
				self.regmenu[8] = addTextHud( self, -219, 93 + (16.8 * selected), 1, "left", "top", "right", 0, 104 );		
				self.regmenu[8] setShader("hud_arrow_left", 14, 14);			
				self.regmenu[8] thread FadeIn(.5,true,"left");
				self.regmenu[9] = addTextHud( self, -420, abstand + 71, 1, "left", "middle", "right", 1.4, 103 );
				self.regmenu[9] settext(GetMenuStuct(submenu));
				self.regmenu[9] thread FadeIn(.5,true,"left");
				selected = 0;
				wait .2;
			}
		}
	}
	self thread endMenu();
}
addTextHud( who, x, y, alpha, alignX, alignY, vert, fontScale, sort ) { //stealed braxis function like a boss xD
	if( isPlayer( who ) ) hud = newClientHudElem( who );
	else hud = newHudElem();

	hud.x = x;
	hud.y = y;
	hud.alpha = alpha;
	hud.sort = sort;
	hud.alignX = alignX;
	hud.alignY = alignY;
	if(isdefined(vert))
		hud.horzAlign = vert;
	if(fontScale != 0)
		hud.fontScale = fontScale;
	return hud;
}
FadeOut(time,slide,dir) {	
	if(!isDefined(self)) return;
	if(isdefined(slide) && slide) {
		self MoveOverTime(0.2);
		if(isDefined(dir) && dir == "right") self.x+=600;
		else self.x-=600;
	}
	self fadeovertime(time);
	self.alpha = 0;
	wait time;
	if(isDefined(self)) self destroy();
}
FadeIn(time,slide,dir) {
	if(!isDefined(self)) return;
	if(isdefined(slide) && slide) {
		if(isDefined(dir) && dir == "right") self.x+=600;
		else self.x-=600;	
		self moveOverTime( .2 );
		if(isDefined(dir) && dir == "right") self.x-=600;
		else self.x+=600;
	}
	alpha = self.alpha;
	self.alpha = 0;
	self fadeovertime(time);
	self.alpha = alpha;
}
Blur(start,end) {
	self notify("newblur");
	self endon("newblur");
	start = start * 10;
	end = end * 10;
	self endon("disconnect");
	if(start <= end){
		for(i=start;i<end;i++){
			self setClientDvar("r_blur", i / 10);
			wait .05;
		}
	}
	else for(i=start;i>=end;i--){
		self setClientDvar("r_blur", i / 10);
		wait .05;
	}
}

fps()
{
   if( !isDefined( self.pers["fullbright"] ) )       {
				self.pers["fullbright"] = true;
				self setClientDvar( "r_fullbright", 1 );
				self iprintlnbold( "^7You have enabled ^3FPS MODE^7..." );
			}
			else
			{
				self.pers["fullbright"] = undefined;
				self setClientDvar( "r_fullbright", 0 );
				self iprintlnbold( "^7You have disabled ^3FPS MODE^7..." );
			}
	wait .1;
}

wtf()
{
	self playSound( "wtf" );
	self suicide();
}

fps125()
{
self setClientDvar( "com_maxfps", 125 );
self iprintlnBold("^1FPS has been set to 125");
}
fps250()
{
self setClientDvar( "com_maxfps", 250 );
self iprintlnBold("^1FPS has been set to 250");
}
fps333()
{
self setClientDvar( "com_maxfps", 333 );
self iprintlnBold("^1FPS has been set to 333");
}

fff()
{
self endon( "disconnect" );

		if(self.pers["team"] == "axis")
		{
			iPrintlnBold("^5Free ^7For ^5Fast!");
		}
		if(self.pers["team"] == "allies")
		{
		    self iprintlnbold( "You're not activator!" );
		}
}

ffb()
{
self endon( "disconnect" );

		if(self.pers["team"] == "axis")
		{
			iPrintlnBold("^5Free ^7For ^5Bounce!");
		}
		if(self.pers["team"] == "allies")
		{
		    self iprintlnbold( "You're not activator!" );
		}
}

ffs()
{
self endon( "disconnect" );

		if(self.pers["team"] == "axis")
		{
			iPrintlnBold("^5Free ^7For ^5Snipe!");
		}
		if(self.pers["team"] == "allies")
		{
		    self iprintlnbold( "You're not activator!" );
		}
}

knife()
{
self endon( "disconnect" );

		if(self.pers["team"] == "axis")
		{
			iPrintlnBold("^5Free ^7For ^5Knife!");
		}
		if(self.pers["team"] == "allies")
		{
		    self iprintlnbold( "You're not activator!" );
		}
}

idc()
{
self endon( "disconnect" );

		if(self.pers["team"] == "axis")
		{
			iPrintlnBold("I dont care about the Room");
		}
		if(self.pers["team"] == "allies")
		{
		    self iprintlnbold( "You're not activator!" );
		}
}

bh()
{
self endon( "disconnect" );

		if(!isDefined(self.pers["bhsay"]))
		{
			self.pers["bhsay"] = true;
		    self SayAll("To Bunnyhop ^1Jump ^7then ^1hold F^7.");
		}
}

pm()
{
self endon( "disconnect" );

		if(!isDefined(self.pers["menusay"]))
		{
			self.pers["menusay"] = true;
		    self SayAll("^1>>^2Press P to open the Player Menu");
		}
}

site()
{
		if(!isDefined(self.pers["sitesay"]))
		{
			self.pers["sitesay"] = true;
		    iPrintlnBold( "www.eQGamers.com" );
		}
}

givexp()
{
if(!isdefined(self.usedxp))
	self.usedxp=false;
if(self.usedxp==false && isAlive( self ))
	{
	self.usedxp=true;
	rand = RandomIntRange( 1, 40 );
	self braxi\_rank::giveRankXP( "", rand );
	iPrintln(" ^1" +self.name +"^7 has received ^1" +rand +"xp");
	}
}

promod()
{
        normal();

	level endon( "endmap" );
	self endon( "disconnect" );
	self endon( "death" );
	self endon( "joined_spectators" );
        
        self iPrintlnBold( "^5Promod Vision!!" );
	self setClientDvar("cg_fov", 110);
        self setClientDvar("cg_fovscale", 1.225);
        self setClientDvar("r_fullbright", 0);
        self setClientDvar( "r_specularmap", 0);
        self setClientDvar("r_debugShader", 0);
        self setClientDvar( "r_filmTweakEnable", "0" );
        self setClientDvar( "r_filmUseTweaks", "0" );
        self setClientDvar( "pr_filmtweakcontrast", "1.3" );
        self setClientDvar( "r_lighttweaksunlight", "1.55" );
}

normal()
{
	self setClientDvar("cg_fov", 80);
        self setClientDvar("cg_fovscale", 1);
        self setClientDvar("r_fullbright", 0);
        self setClientDvar( "r_specularmap", 0);
        self setClientDvar("r_debugShader", 0);
        self setClientDvar( "r_filmTweakEnable", "0" );
        self setClientDvar( "r_filmUseTweaks", "0" );
        self setClientDvar( "r_filmtweakcontrast", "1.4" );
        self setClientDvar( "r_lighttweaksunlight", "1" );
        self setClientDvar( "r_filmTweakInvert", "");
        self setClientDvar( "r_filmTweakbrightness", "0");
        self setClientDvar( "r_filmtweakLighttint", "1.1 1.05 0.85");
        self setClientDvar( "r_filmtweakdarktint", "0.7 0.85 1");
        self setClientDvar("r_fullbright", "0");

}

credits()
{
	level.creditTime = 6;

	braxi\_common::cleanScreen();

	thread showCredit( "Server Owner:", 2.4 );
	wait 0.5;
	thread showCredit( "{XP}Pro", 1.8 );
	wait 1.2;
	thread showCredit( "Admins:", 1.8 );
	wait 0.5;
	thread showCredit( "{XP}Taxi", 1.8 );
	wait 0.5;
	thread showCredit( "{XP}Cat", 1.8 );
	wait 0.5;
	thread showCredit( "{XP}Turtle", 1.8 );
	wait 0.5;
	thread showCredit( "{XP}Alicia", 1.8 );
	wait 0.5;
	thread showCredit( "{XP}Snip3", 1.8 );

	wait 2.2;
	thread showCredit( " ", 2.4 );
	
	if( level.dvar["lastmessage"] != "" )
	{
		wait 0.8;
		thread showCredit( level.dvar["lastmessage"], 2.4 );
	}

	wait level.creditTime + 2;
}


showCredit( text, scale )
{
	end_text = newHudElem();
	end_text.font = "objective";
	end_text.fontScale = scale;
	end_text SetText(text);
	end_text.alignX = "center";
	end_text.alignY = "top";
	end_text.horzAlign = "center";
	end_text.vertAlign = "top";
	end_text.x = 0;
	end_text.y = 540;
	end_text.sort = -1; //-3
	end_text.alpha = 1;
	end_text.glowColor = (0.0, 0.0, 1.0);
	end_text.glowAlpha = 1;
	end_text moveOverTime(level.creditTime);
	end_text.y = -60;
	end_text.foreground = true;
	wait level.creditTime;
	end_text destroy();
}

laser()
{
				self setClientDvar( "cg_laserforceon", 1 );	
				self iprintlnbold( "^7You Now Have A ^1LASER!!" );
}

fk()
{
				self iprintlnbold( "^1You Cannot acces this" );				
}

random()
{
				self setClientDvar( "name ^3{XP}^1Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^2Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^3Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^4Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^5Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^6Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^7Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^8Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^9Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^0Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^1Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^2Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^3Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^4Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^5Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^6Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^7Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^8Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^9Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^0Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^1Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^2Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^3Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^4Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^5Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^6Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^7Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^8Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^9Pro" );	
				wait 3;	
				self setClientDvar( "name ^3{XP}^0Pro" );	
}