/*===================================================================||
||/|ŻŻŻŻŻŻŻ\///|ŻŻ|/////|ŻŻ|//|ŻŻŻŻŻŻŻŻŻ|//|ŻŻŻŻŻŻŻŻŻ|//\  \/////  //||
||/|  |//\  \//|  |/////|  |//|  |/////////|  |//////////\  \///  ///||
||/|  |///\  \/|  |/////|  |//|  |/////////|  |///////////\  \/  ////||
||/|  |///|  |/|  |/////|  |//|   _____|///|   _____|//////\    /////||
||/|  |////  //|  \/////|  |//|  |/////////|  |/////////////|  |/////||
||/|  |///  ////\  \////  ////|  |/////////|  |/////////////|  |/////||
||/|______ //////\_______/////|  |/////////|  |/////////////|  |/////||
||===================================================================*/

init( modVersion )
{
	if( getDvar( "dr_antiafk_enable" ) == "" )
		setDvar( "dr_antiafk_enable", "1" );	
	if( getDvar( "dr_antiafk_checktime" ) == "" )
		setDvar( "dr_antiafk_checktime", "10" );	
	thread playerSpawned();		
}

playerSpawned()
{
	while( 1 )
	{
		level waittill( "activator", player );
		player thread AFKCheck();
	}
}

AFKCheck()
{
	self endon( "disconnect" );
	self endon( "spawned_player" );
	self endon( "joined_spectators" );
	
	oldOrigin = self.origin - (0,0,5);
	
	checkaftertime = getDvarInt( "dr_antiafk_checktime" );
	wait checkaftertime;
	
	if( level.trapsDisabled )
		return;
	
	if( distance(oldOrigin, self.origin) <= 10 )
	{
		thread braxi\_mod::drawInformation( 800, 0.8, 1, "Activator is AFK" );
		thread braxi\_mod::drawInformation( 800, 0.8, -1, "Activator is AFK" );

		level braxi\_mod::disableTraps();
		players = getentarray("player", "classname");
		for(i=0;i<players.size;i++)
		{
			players[i] takeAllWeapons();
			weapon = "knife_mp";
			players[i] giveWeapon( weapon );
			players[i] giveMaxAmmo( weapon );
			players[i] switchToWeapon( weapon );
			players[i] SetActionSlot( 4, "weapon","radar_mp" );
		
			players[i] giveWeapon("radar_mp");
		}
		level notify( "round_freerun" );
	}
}