Here is my code once more.
Code:
entity* ghostobject;
var isplaceobject;
function spawn()
{
   isplaceobject = 1;
	while(isplaceobject != 0)
	{
	temp.x = mouse_pos.x;
	temp.y = mouse_pos.y;
	temp.z = 0;
	
	vec_set(target,temp);
	target.z = 10000;
	
	vec_for_screen(temp,view_build);
	vec_for_screen(target,view_build);
	
	if(c_trace(temp,target,IGNORE_ME | IGNORE_PASSABLE) > 0)
	{
		if(mouse_left)
		{
			ent_create("crate.mdl",target,null);
			if(ghostobject != NULL)
			{
				ent_remove(ghostobject);
				isplaceobject = 0;
				return;
			}	
		}
		if(ghostobject == NULL)
		{
			ghostobject = ent_create("crate.mdl",target,NULL);
			ghostobject.transparent = on;
			ghostobject.passable = on;
			ghostobject.alpha = 30;
		}
		else
		{
			vec_set(ghostobject.x,target);
		}
		
	}	
		wait(1);
	}
	

}



The problem is coming from when i hold down the left mouse buttons they just keep spawning in a huge line all the way up to the camera, then the engine crashes due to too many entities. Is there a way where even if i hold the left mouse button down it will only run that if statement once? Also im running the function by putting spawn(); in another function.

Last edited by binsky33333; 08/06/09 17:26.