Skip to content

Commit

Permalink
implement custom colshape events
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonMrBonnie committed Mar 18, 2023
1 parent 4779ae4 commit df57724
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions shared/js/events/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
3 changes: 3 additions & 0 deletions shared/src/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace js
{
NONE,

ENTITY_ENTER_COLSHAPE,
ENTITY_LEAVE_COLSHAPE,

SIZE
};

Expand Down

0 comments on commit df57724

Please # to comment.