You can do it like this:

Code:
entity* theGun;

function gun_function()
{
	my.passable = on;
	my.ambient = 0;
	vec_scale(my.scale_x,2);
	
	while(my)
	{
		vec_set(my.pan,camera.pan);	// Same angle as camera
		
		vec_set(my.x,camera.x);		// Same position as camera
		
		// play around with these values
		my.x += 5;
		my.y += 0;
		my.z += 0;
		
		wait(1);
	}
}

function createGun()
{
	if(theGun != null) {ent_remove(theGun);}
	
	theGun = ent_create("el_revolver.mdl",camera.x,gun_function);
}



Edit: If you want multiple guns, I suppose it's better to use ent_morph to change the gun model, instead of creating multiple gun entities and switching which one is visible smile

Last edited by Claus_N; 08/23/09 09:23.