Can You Directly Purchase A Hotel If All Houses Are Gone?
No.

You can only build a hotel if you have four houses on your properties.

You must build houses evenly.  That is, if you have three properties, then you must buy 1 house for A, 1 house for B, 1 house for C, 2nd house for A, 2nd house for B, 2nd house for C, and so on.

You cannot buy a hotel on one property.

If the houses are gone, then you cannot buy them.

https://www.hasbro.com/common/instruct/monins.pdf