In SCS there's already an optional component that prevents you from sleeping more than once in the first dungeon. It doesn't disable the rest button, but if you try to rest more than once, you are always ambushed. Probably this the easiest way to script it (location-based restrictions rather than time based).
@The Imp, thanks for the link, that guide is massive, can you recommend which sections should I really know (at least for starting)?