I'm not sure if this function still works or not, but I used to call it when the entity was hit (no while loop).

Code:
function show_damage(var* pos, damage) {
	var duration = 20;
	VECTOR loc_pos;
	TEXT* txt_damage_points = txt_create(1,2);
	txt_damage_points.font = font_create("Arial#25b");
	set(txt_damage_points,LIGHT | OUTLINE | CENTER_X | CENTER_Y);
	txt_damage_points.red = 255;
	txt_damage_points.green = 53;
	txt_damage_points.blue = 5;
	str_cpy((txt_damage_points.pstring)[0],str_for_num(NULL,damage));
	vec_set(loc_pos,pos);
	proc_mode = PROC_GLOBAL;
	while(duration > 0) {
		vec_set(temp,loc_pos);
		if(vec_to_screen(temp,camera)) {
			set(txt_damage_points,SHOW);
			txt_damage_points.pos_x = temp.x;
			txt_damage_points.pos_y = temp.y-50+duration;
		}
		else {
			reset(txt_damage_points,SHOW);
		}
		duration -= time_step;
		wait(1);	
	}
	reset(txt_damage_points,SHOW);
	ptr_remove((txt_damage_points.pstring)[0]);
	ptr_remove(txt_damage_points);
}




"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends