OneSync: intercepting game events (such as explosions)

Originally published at: https://cookbook.fivem.net/2019/08/19/onesync-intercepting-game-events-such-as-explosions/

The latest version of the Windows server added support for parsing and preventing routing of game events. This currently only supports parsing CExplosionEvent, but this might be a fairly useful one to prevent routing of ‘excessive’ explosions, or explosions that are ‘too close’ to a player and not of the correct weapon type. Here’s an…

10 Likes

Ok wow this is pretty fucking epic O.O

My hope is for this same method of verification to be able to be useable for all types of Client Events

Might be taxing but if not that would be megaepic

Good work team!

1 Like

This looks pretty! Definitely use this :exploding_head:

Wow ! Anticheat update here i come !

We’re using Sticky Bombs to test the event, it triggers the event on the server side; however it doesn’t cancel the event to stop the explosion.

Any ideas?

AddEventHandler('explosionEvent', function(sender, ev)
    if (ev.damageScale ~= 0.0) then
            CancelEvent()
            ev.damageScale = 0.0
            TriggerEvent('explosionEvent', sender, ev)
    end
end)
1 Like

To add on to LanceGood’s post, this code whilst it does print the data, the event is not cancelled and explosions will still kill a player…

Such a shame, I was really looking forward to using this as soon as it came out…

AddEventHandler('explosionEvent', function(sender, ev)
    CancelEvent()
    print(GetPlayerName(sender), json.encode(ev))
end)
2 Likes

Weapon explosions are having a separate weapon damage event which is currently not hookable. This is mainly for script explosions as used by mass kill options in menus.

1 Like

Does this mean using the above event will work for AddExplosion exploiting currently and stop all the modders from exploding using their menus? Also, is there an event which can handle all explosions?

Best Regards,
Badger

1 Like

The RPG will trigger this event.

Also, I’m currently having a problem with this event.
I’m getting spammed with apparently invalid explosions out of nowhere:

I’m thinking about just filtering out explosions with damageScale 0.

Awesome. Please make other game event too like CreateVehicle, Ped ?

1 Like

how to active this resource?