Skip to content

Commit

Permalink
feat: leave bed event
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsubasa6848 committed Mar 4, 2024
1 parent 39a798d commit 8864421
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/EventAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ void Export_Event_API() {
);
return true;
}
case do_hash("onLeaveBed"): {
auto Call = RemoteCall::importAs<bool(Player * pl)>(eventName, eventId);
eventBus->emplaceListener<GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent>(
[Call](GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) {
bool result = true;
try {
result = Call(&ev.self());
} catch (...) {}
if (!result) {
ev.cancel();
}
}
);
return true;
}
default:
return false;
}
Expand Down

0 comments on commit 8864421

Please sign in to comment.