I have set the main function to:

function main()
{ var i; var j;
vec_set(sky_color,vector(0,0,0));
level_load(NULL);
video_window(NULL,NULL,0,"Laser demo");
vec_set(camera.x,vector(-250,0,50));
vec_set(camera.pan,vector(0,-15,0));
while (1){
if (mouse_left == 1){
if(proc_status(tracer_right) < 5){gun1=ent_create(NULL,vector(-100,-170,-80),tracer_right);i++;}
if(proc_status(tracer_left) < 5){gun2=ent_create(NULL,vector(-100,170,-80),tracer_left);j++;}
}
if((proc_status(tracer_right) == 0) && (i>0)){ptr_remove(gun1);i--;}
if((proc_status(tracer_left) == 0) && (j>0)){ptr_remove(gun2);j--;}
wait(1);
}
}

but still though very rarely I get that error.