The OnPlayerRest event is fired when a player character attempts to rest, when that resting is interrupted or canceled, and when that resting is finished. Scripts for this event usually need to check why the script fired.
Resting can be blocked by assigning
ClearAllActions() to a character who is starting to rest. This will cancel the rest (and hence immediately trigger another OnPlayerRest event, this one of the "canceled" type).