PANEL* pan_crosshair =
{
bmap = your_bmap;
}
ENTITY* nearest_plane;
function crosshair()
{
VECTOR temp;
while(1)
{
if(nearest_plane != NULL) // check if nearest plane exists
{
vec_set(temp,nearest_plane.x);
if (vec_to_screen(temp,camera) != NULL) // if visible on screen, convert to screen coordinates
{
pan_crosshair.pos_x = integer(temp.x - bmap_width(your_bmap) / 2); // place the crosshair
pan_crosshair.pos_y = integer(temp.y - bmap_height(your_bmap) / 2);;
set(pan_crosshair,SHOW);
}
else
{
reset(pan_crosshair,SHOW);
}
}
else
{
reset(pan_crosshair,SHOW);
}
wait(1);
}
}
action plane()
{
while(me)
{
if(vec_dist(my.x,camera.x) < vec_dist(nearest_plane.x,camera.x)) // Check if not the nearest plane
nearest_plane = me; // Set to the nearest plane
wait(1);
}
}