A method is presented that allows one to compute the maximum number of functionally-independent invariant functions under the action of a linear algebraic group as long as its Lie algebra admits a basis of square-zero matrices even on a field of positive characteristic. The class of such Lie algebras is studied in the framework of the classical Lie algebras of arbitrary characteristic. Some examples and applications are also given.