I created my own little flashlight script.
However There are still some areas which just stay black...

Code:
function handle_flashlight()
{
	wait(5);
	set(my,PASSABLE|INVISIBLE);
	//
	wait(1);
	while(player)
	{	
		VECTOR trace_coords;
		ANGLE trace_ang;
		//////////
		if(player.state != 2)
		{
			vec_set(trace_coords.x,vector(1000,0,0));
			vec_rotate(trace_coords.x,camera.pan);
			vec_add(trace_coords.x,camera.x);
			c_trace(camera.x,trace_coords.x,IGNORE_ME|ACTIVATE_SHOOT);
		}
		else
		{
			vec_for_bone(trace_coords.x, player, "light_point");
			ang_for_bone(trace_ang.pan, player, "light_point");
			c_trace(trace_coords.x,vec_rotate(vector(1000,0,0),trace_ang.pan),IGNORE_ME|ACTIVATE_SHOOT);
		}
		if(trace_hit)
		{
			my.x = hit.x + 50;
			my.y = hit.y;
			my.z = hit.z;
		}
		else
		{
			if(!trace_hit)
			{
				my.x = trace_coords.x;
				my.y = trace_coords.y;
				my.z = trace_coords.z;
			}
		}
		my.lightrange = vec_dist(camera.x,my.x) * 0.5;
		my.red = 255 - ( vec_dist(camera.x,my.x) * 0.1 );
		my.green = 255 - ( vec_dist(camera.x,my.x) * 0.1 );
		my.blue = 255 - ( vec_dist(camera.x,my.x) * 0.1 );
		wait(1);
	}
}



Any suggestions how to make it work properly?

PS: thank you masterQ32. It does work better now, but still not properly.