Well I would say neither of those codes could have worked.

In the A6 code youre setting the z position to the result of a trace, this does not make sense to me unless by some chance the floor is exactly at 0 position.

The A7 code will even crash, youre using vec_set with a z value, this will write past the target vector and trash the memory. You probably meant to change the z value only but can not use vec_set then.

For gravity theres no difference between A6 and A7 so you can use the same function. This is from the online manual:

Code:
// determine the ground distance by a downwards trace
		var dist_to_ground; 
		VECTOR vFeet;
		vec_for_min(vFeet,me); // vFeet.z = distance between player origin and lowest player vertex
		result = c_trace(my.x, vector(my.x,my.y,my.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX);
		if (result > 0)
			dist_to_ground = my.z + vFeet.z - target.z; // the distance between player's feet and the ground
		else
			dist_to_ground = 0;


and then:

m.z -= dist_to_ground;

or:

my.z = target.z - vFeet.z; (dont need dist_to_ground in that case)

I hope this helps.