To make your code a bit more bulletproof, change your entity declares to this
ENTITY* mangyanenemy = NULL; or ENTITY* mangyanenemy = 0;
PANEL* pan_backselectenemy = NULL; or PANEL* pan_backselectenemy = 0;
Now you can test if the entity is in use or not.

To see this test in action, and to possibly fix your problem, change the following too.
Code:
function func_backselectenemy()
{  if(mangyanenemy!=NULL) ent_remove(mangyanenemy);                 mangyanenemy=NULL;
   if(pan_backselectenemy!=NULL) pan_remove(pan_backselectenemy);   pan_backselectenemy=NULL;
   if(townlevel!=NULL) ent_remove(townlevel);                       townlevel=NULL;
}

let us know how it goes.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial