Damage Events [dev release] v1.0.0 - Simple events for all kinds of damage/death game-events

Damage Events

This resource provides events for pretty much all entity related damage or death events by listening to the gameEventTriggered event, taking the data and triggering new events based on that game event data.

:warning: please read

This is considered a dev release. If you are a server owner and don’t know how to create resources yourself, then this is NOT for you! You should use this if you’re making a resource and want to listen for damage or death events without implementing the code yourself.


Download

You can download it here.


Debugging

There is an option in the __resource.lua file that allows you to turn on debug prints. This will print all triggered events to the F8 console. Note that you should disable this on your live server because it does reduce performance, and it just spams the console and client log of your users.


Events reference

See this page for a list of all events, or checkout the GitHub page, it’s listed in the README.md there as well.

There are 8 events in total, all of which have been documented in the README file or at the page linked above.

All events are triggered on the CLIENT SIDE only, there is no server side events with network ID’s (yet).

Note, only one event will be triggered for every game event. Only the one that’s most appropriate in any given situation will be used.

For example, if a player kills a ped, only the DamageEvents:PedKilledByPlayer event will be triggered, events like DamageEvents:PedDied or DamageEvents:EntityKilled will not be triggered in that case.


Bugs

I have not tested this with a lot of players online, all I know is that it works fine for 2 players.

22 Likes

YAS @Vespura! Thanks for the release! I was just about to make something like this so I could have it! Thanks again and keep up the great work man!

1 Like

This is not severely tested, let me know if you have any issues using it. Or if you have suggestions, feel free to let me know or provide a PR, for now I’d like to keep it damage/death related, so no miscellaneous events.

1 Like

Nice usage of the gameEvent stuff. I’m totally going to use this for my own purposes <3
Possibly re-write it to my own framework.

1 Like

Hello Friend !

I’d like to know how long it takes for the first event to appear

Have a good afternoon

depends on whenever any entity takes damage around you… try shooting or attacking some ped near you, or crash your car into a wall.

Very unique and good release! Great job, Will be useful! :slight_smile:

1 Like

Great resource hope you in the future add other events
Thank you very much

1 Like

You came in clutch. I needed “Ped killed by player” for a new gamemode that I started yesterday and I was dreading going through the game events / CEventNetworkEntityDamage logic.

Works like a charm.

Fast :white_check_mark:
Lightweight :white_check_mark:
Copied it straight into my code with nice little remark about you :white_check_mark:

:heart:

2 Likes

Amazing release as always @Vespura

1 Like

I shall be waiting eagerly for the addition of NetworkID Support!

Loving that the event triggers for everyone, but then the ability to filter out everyone BUT the player to trigger the event… oof, the possibilities!

1 Like

Hey there,
I don’t suppose you found a reliable way to receive the correct ID for the shooter?

I’m considering ideas of tracking shots to identify who shot the ped last, but given I’m only recently returning to the FiveM scene, there’s likely more reliabe ways

Using the CEventNetworkEntityDamage for gameEventTriggered is probably the most reliable one. Specifically “Ped killed by player” if you’re wanting to track which player shot a ped last.

1 Like

Can you clarify? I’m not sure what you’re trying to say here.

FYI, all CEventNetworkEntityDamage data is already included in this resource.

My apologies! I’ll try to explain further,

I found that during testing (that being an “alert” being sent when a ped is killed by a player), I found that every online user would get that event, and the ID for the player that killed the ped would return as 0. Originally, I thought the DamageEvent might only trigger on the shooters client script, which then I could figure it out, but that isn’t the case.

It would return as 0 for the player ID regardless of which player killed the ped, so I’m unable to find which player was the one to kill the ped.

You mention in your OP that NetworkID is unsupported at the moment, so I wasn’t sure how I might get actual shooter’s ID.

Hopefully that clarifies some things :+1:t2:

That’s really strange… it shouldn’t just return 0 all the time, I’ll look into it.

Are you using this on onesync or a default server?

Sorry, I didn’t mean to cause you additional work :sweat_smile:

At least with the Player killing Ped event, it returns 0, Damage by a player returns an actual ID. And yes this is using the default server.

I don’t suppose you were able to make any sense of the issue I was experiencing?

Still seems to be happening for me, is there any configuration I may need to change on my end or something?

I have not had the time yet to look into it.

Alright, no worries!

I did some more experimenting, noticed I was using tostring() to print the number, so it’s actually returning nil rather than 0. So I guess it’s literally returning null for the attacker.

Damage itself still works fine, it’s just the killing :pray:t2:

1 Like