From df577247a03fae10059b653452d8121998c41e37 Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Sat, 18 Mar 2023 19:51:13 +0100 Subject: [PATCH] implement custom colshape events --- shared/js/events/script.js | 12 ++++++++++++ shared/src/Event.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/shared/js/events/script.js b/shared/js/events/script.js index 00b7da1f0..2fdba719b 100644 --- a/shared/js/events/script.js +++ b/shared/js/events/script.js @@ -6,3 +6,15 @@ Event.register(alt.Enums.EventType.COLSHAPE_EVENT, "ColShapeEvent"); Event.register(alt.Enums.EventType.EXPLOSION_EVENT, "Explosion"); Event.register(alt.Enums.EventType.FIRE_EVENT, "FireStart"); Event.register(alt.Enums.EventType.START_PROJECTILE_EVENT, "ProjectileStart"); + +// Custom ColShape events +Event.register(alt.Enums.CustomEventType.ENTITY_ENTER_COLSHAPE, "EntityColShapeEnter", true); +Event.register(alt.Enums.CustomEventType.ENTITY_LEAVE_COLSHAPE, "EntityColShapeLeave", true); +alt.Events.onColShapeEvent(({ entity, colShape, state }) => { + const type = state ? alt.Enums.CustomEventType.ENTITY_ENTER_COLSHAPE : alt.Enums.CustomEventType.ENTITY_LEAVE_COLSHAPE; + const data = { + entity, + colShape + }; + Event.invoke(type, data, true); +}); diff --git a/shared/src/Event.h b/shared/src/Event.h index 9c3bf61a6..4a8ac0a5f 100644 --- a/shared/src/Event.h +++ b/shared/src/Event.h @@ -15,6 +15,9 @@ namespace js { NONE, + ENTITY_ENTER_COLSHAPE, + ENTITY_LEAVE_COLSHAPE, + SIZE };