You can quite easily check if a player is in a spot where they can not stand up using a EngFunc_TraceHull call. Simply get the origin and add some amount to the z axis (going upwards) and use that as the trace target. If TR_AllSolid is false and TR_flFraction is smaller than 1.0 the player is in a space where they can not stand up. You maybe have to play around a little with how far you need to move up to accurately detect this.