main() //sctips by dAfuq İİ
{
	maps\mp\_load::main();
	
	ambientPlay("bullseye");

	
	
/////////Thread's\\\\\\\\



		


	thread credit();
	thread door();
	thread sniper();
	thread deagle();
	thread knife();
	thread text();
	thread addTestClients();
	thread trap1();
	thread trap2();
	thread trap3();
	thread trap4();
	thread trap5();
	thread trap6();
	thread trap7();
	thread trap8();
	
	

					addTriggerToList("trap1_trig");
					addTriggerToList("trap2_trig");
					addTriggerToList("trap3_trig");
					addTriggerToList("trap4_trig");
					addTriggerToList("trap5_trig");
					addTriggerToList("trap6_trig");
					addTriggerToList("trap7_trig");
					addTriggerToList("trap8_trig");	
}

addTriggerToList( name )
{
    if( !isDefined( level.trapTriggers ) )
        level.trapTriggers = [];
    level.trapTriggers[level.trapTriggers.size] = getEnt( name, "targetname" );
}
credit()
{
wait(10);
thread drawInformation( 800, 0.8, 1, "^7Colours my first map^1... " );
wait(5);
thread drawInformation( 800, 0.8, 1, "^7Map by Dafuq^1.." );
}

drawInformation( start_offset, movetime, mult, text )
{
	start_offset *= mult;
	hud = new_ending_hud( "center", 0.1, start_offset, 90 );
	hud setText( text );
	hud moveOverTime( movetime );
	hud.x = 0;
	wait( movetime );
	wait( 3 );
	hud moveOverTime( movetime );
	hud.x = start_offset * -1;

	wait movetime;
	hud destroy();
}
new_ending_hud( align, fade_in_time, x_off, y_off )
{
	hud = newHudElem();
    hud.foreground = true;
	hud.x = x_off;
	hud.y = y_off;
	hud.alignX = align;
	hud.alignY = "middle";
	hud.horzAlign = align;
	hud.vertAlign = "middle";

 	hud.fontScale = 3;

	hud.color = (1, 1, 1);
	hud.font = "objective";
	hud.glowColor = (0, 0.1, 0);
	hud.glowAlpha = 1;

	hud.alpha = 0;
	hud fadeovertime( fade_in_time );
	hud.alpha = 1;
	hud.hidewheninmenu = true;
	hud.sort = 10;
	return hud;
}
door()
{
	door_a = getEnt ("door_a", "targetname");
	door_b = getEnt ("door_b", "targetname");
	trig = getEnt ("door_trig", "targetname");
	
	trig waittill( "trigger" );
	trig delete();
	

	door_A moveY (8, 3);
	wait 0.01;
	door_b moveZ (-241, 3);
	wait 5;
	door_b delete();
}
trap1()
{
	trap1_1 = getEnt ("trap1_1", "targetname");
	trap1_2 = getEnt ("trap1_2", "targetname");
	trap1_a = getEnt ("trap1_a", "targetname");
	trap1_b = getEnt ("trap1_b", "targetname");
	trap1_c = getEnt ("trap1_c", "targetname");
	trap1_d = getEnt ("trap1_d", "targetname");
	trap1_e = getEnt ("trap1_e", "targetname");
	trap1_f = getEnt ("trap1_f", "targetname");
	trig = getEnt ("trap1_trig", "targetname");
	
	trig waittill( "trigger" );
	trig delete();
	
	while(1)
	{
	trap1_1 rotateroll(360, 3);
	wait 0.00001;
	trap1_2 rotateroll (-360, 3);
	wait 0.00001;
	trap1_a rotateYaw (360, 2);
	wait 0.00001;
	trap1_b rotateYaw (360, 2);
	wait 0.00001;
	trap1_c rotateYaw (360, 2);
	wait 0.00001;
	trap1_d rotateYaw (360, 2);
	wait 0.00001;
	trap1_e rotateYaw (360, 2);
	wait 0.00001;
	trap1_f rotateYaw (360, 2);
	}
}
trap2()
{
	trap2_a = getEnt ("trap2_a", "targetname");
	trap2_b = getEnt ("trap2_b", "targetname");
	trap2_c = getEnt ("trap2_c", "targetname");
	trig = getEnt ("trap2_trig", "targetname");
	
	trig waittill( "trigger" );
	trig delete();
	

	trap2_a moveZ (-208, 3);
	wait 2;
	trap2_b moveZ (-208, 3);
	wait 2;
	trap2_c moveZ (-208, 3);
	wait 15;
	trap2_a moveZ (208, 3);
	wait 2;
	trap2_b moveZ (208, 3);
	wait 3;
	trap2_c moveZ (208, 3);
}
trap3()
{
	trap3 = getEnt ("trap3", "targetname");
	trig = getEnt ("trap3_trig", "targetname");
	
	trig waittill ("trigger");
	trig delete();
	
	while(1)
	{
	wait 1;
	trap3 rotateYaw (360, 2.5);
	wait 1;
	}

}
trap4()
{
	trap4 = getEnt ("trap4", "targetname");
	trig = getEnt ("trap4_trig", "targetname");
	
	trig waittill ("trigger" );
	trig delete();
	
	while(1)
	{
	trap4 moveZ (-208, 1);
	trap4 waittill("movedone");
	wait 15;
	trap4 moveZ (208, 4);
	trap4 waittill("movedone");
	}
	
}
trap5()
{
      trap5 = getEnt ("trap5", "targetname");
	  trig = getEnt ("trap5_trig", "targetname");
	  
	  trig waittill ("trigger", player);
	  trig delete();
	  
	  trap5 notsolid();
}
trap6()
{
	trap6 = getEnt ("trap6", "targetname");
	trig = getEnt ("trap6_trig", "targetname");

	trig waittill ("trigger");
	trig delete();
	
	while(1)
	{
	trap6 moveY (848, 1.2);
	trap6 waittill("movedone");
	wait 0.01;
	trap6 moveY (-840, 1);
	trap6 waittill("movedone");
	}
}
trap7()
{
	trap7_a = getEnt ("trap7_a", "targetname");
	trap7_b = getEnt ("trap7_b", "targetname");
	trig = getEnt ("trap7_trig", "targetname");
	
	trig waittill( "trigger" );
	trig delete();
	
	while(1)
	{
	trap7_a rotateroll (360, 3);
	wait 0.5;
	trap7_b rotateroll (-360, 3.1);
	wait 15;
	trap7_a waittill("movedone");
	trap7_b waittill("movedone");
	}	
}
trap8()
{
	trap8 = getEnt ("trap8", "targetname");
	trig = getEnt ("trap8_trig", "targetname");
	
	trig waittill ("trigger");
	trig delete();
	
	while(1)
	{
	trap8 rotateYaw (360, 2.5);
	wait 1;
	}
}


	
sniper()
{
   
	level.final_trigger = getEnt( "final_trigger", "targetname");
    jump = getEnt( "enter_jumper_room", "targetname" );
    acti = getEnt( "activator_enter_jump", "targetname" );
	

     while(1)
    {
        level.final_trigger waittill( "trigger", player );
        if( !isDefined( level.final_trigger ) )
            return;
        
		level.final_trigger_k delete();
        level.final_trigger_d delete();
		
		
         player.health = player.maxhealth;
		 level.activ.health = level.activ.maxhealth;
		player SetPlayerAngles( jump.angles );
        player setOrigin( jump.origin );
        player TakeAllWeapons();
        player GiveWeapon( "remington700_mp" );
		player GiveWeapon( "m40a3_mp" );        
        level.activ setPlayerangles( acti.angles );
        level.activ setOrigin( acti.origin );
        level.activ TakeAllWeapons();
        level.activ GiveWeapon( "remington700_mp" );
        level.activ GiveWeapon( "m40a3_mp" );         
        wait 0.05;
        player switchToWeapon( "remington700_mp" ); 
        level.activ SwitchToWeapon( "remington700_mp" );
        player FreezeControls(1);
		level.activ FreezeControls(1);
		noti = SpawnStruct();
				noti.titleText = "Sniper Room";
				noti.notifyText = level.activ.name + " ^3VS^7 " + player.name;
				noti.glowcolor = (0,0.1,0.9);
				noti.duration = 5;
				players = getentarray("player", "classname");
				for(i=0;i<players.size;i++)
					players[i] thread maps\mp\gametypes\_hud_message::notifyMessage( noti );
				wait 5;
				player FreezeControls(0);
				level.activ FreezeControls(0);
        while( isAlive( player ) && isDefined( player ) )
            wait 1;
			
    }

}

knife()
{
   
	level.final_trigger_k = getEnt( "final_trigger_k", "targetname");
    jump = getEnt( "enter_jumper_k", "targetname" );
    acti = getEnt( "activator_enter_k", "targetname" );
	
     while(1)
    {
        level.final_trigger_k waittill( "trigger", player );
        if( !isDefined( level.final_trigger_k ) )
            return;
        
        level.final_trigger_d delete();
        level.final_trigger delete();
      
         player.health = player.maxhealth;
		 level.activ.health = level.activ.maxhealth;
		player SetPlayerAngles( jump.angles );
        player setOrigin( jump.origin );
        player TakeAllWeapons();
        player GiveWeapon( "knife_mp" );
		player GiveWeapon( "knife_mp" );        
        level.activ setPlayerangles( acti.angles );
        level.activ setOrigin( acti.origin );
        level.activ TakeAllWeapons();
        level.activ GiveWeapon( "knife_mp" );
        level.activ GiveWeapon( "knife_mp" );         
        wait 0.05;
        player switchToWeapon( "knife_mp" ); 
        level.activ SwitchToWeapon( "knife_mp" );
        player FreezeControls(1);
		level.activ FreezeControls(1);
		noti = SpawnStruct();
				noti.titleText = "Knife Room";
				noti.notifyText = level.activ.name + " ^3VS^7 " + player.name;
				noti.glowcolor = (0,0.1,0.9);
				noti.duration = 5;
				players = getentarray("player", "classname");
				for(i=0;i<players.size;i++)
					players[i] thread maps\mp\gametypes\_hud_message::notifyMessage( noti );
				wait 5;
				player FreezeControls(0);
				level.activ FreezeControls(0);
        while( isAlive( player ) && isDefined( player ) )
            wait 1;
			
    }

}

deagle()
{
   
	level.final_trigger_d = getEnt( "final_trigger_d", "targetname");
    jump = getEnt( "enter_jumper_d", "targetname" );
    acti = getEnt( "activator_enter_d", "targetname" );
	    
     while(1)
    {
		
        level.final_trigger_d waittill( "trigger", player );
        if( !isDefined( level.final_trigger_d ) )
            return;
        
        level.final_trigger_k delete();
        level.final_trigger delete();
      
         player.health = player.maxhealth;
		 level.activ.health = level.activ.maxhealth;
		player SetPlayerAngles( jump.angles );
        player setOrigin( jump.origin );
        player TakeAllWeapons();
        player GiveWeapon( "deserteagle_mp" );
		player GiveWeapon( "deserteaglegold_mp" );  
		player giveMaxammo("deserteagle_mp");
		player giveMaxammo("deserteaglegold_mp");		
        level.activ setPlayerangles( acti.angles );
        level.activ setOrigin( acti.origin );
        level.activ TakeAllWeapons();
        level.activ GiveWeapon( "deserteagle_mp" );
        level.activ GiveWeapon( "deserteaglegold_mp" ); 
		level.activ giveMaxammo("deserteagle_mp");
		level.activ giveMaxammo("deserteaglegold_mp");        
        wait 0.05;
        player switchToWeapon( "deserteagle_mp" ); 
        level.activ SwitchToWeapon( "deserteagle_mp" );
        player FreezeControls(1);
		level.activ FreezeControls(1);
		noti = SpawnStruct();
				noti.titleText = "Deagle Room";
				noti.notifyText = level.activ.name + " ^3VS^7 " + player.name;
				noti.glowcolor = (0.5,0.9,0.5);
				noti.duration = 5;
				players = getentarray("player", "classname");
				for(i=0;i<players.size;i++)
					players[i] thread maps\mp\gametypes\_hud_message::notifyMessage( noti );
				wait 5;
				player FreezeControls(0);
				level.activ FreezeControls(0);
        while( isAlive( player ) && isDefined( player ) )
            wait 1;
			
    }

}

addTestClients()
{
    setDvar("scr_testclients", "");
    wait 1;
    for(;;)
    {
        if(getdvarInt("scr_testclients") > 0)
            break;
        wait 1;
    }
    testclients = getdvarInt("scr_testclients");
    setDvar( "scr_testclients", 0 );
    for(i=0;i<testclients;i++)
    {
        ent[i] = addtestclient();

        if (!isdefined(ent[i]))
        {
            println("Could not add test client");
            wait 1;
            continue;
        }
        ent[i].pers["isBot"] = true;
        ent[i] thread TestClient("autoassign");
    }
    thread addTestClients();
}

TestClient(team)
{
    self endon( "disconnect" );

    while(!isdefined(self.pers["team"]))
        wait .05;
        
    self notify("menuresponse", game["menu_team"], team);
    wait 0.5;
}

text()
{
	textk = getEnt ("textk", "targetname");
	textb = getEnt ("textb", "targetname");
	texts = getEnt ("texts", "targetname");
	
	while(1)
	{
	textk rotateYaw (360, 4);
	wait 1;
	textb rotateYaw (360, 4);
	wait 1;
	texts rotateYaw (360, 4);
	}
}