My exact code is: AddExplosion(PlayerPos.x+1, PlayerPos.y+5, PlayerPos.z, 9, 0.9, 1, 0, 1065353216, 0)
But when I trigger the explosion, they don’t cause any damage. I tried adding the 9th parameter for enabling damage, and it makes no difference with or without, either way.
It doesn’t seem very well documented. One has to dig deeply in to the source of FiveM to uncover these events. Also, it looks like OneSync is required.
This looks like it’s being worked on and discussed as we speak actually.
AddEventHandler("CEventShockingGunshotFired"
I’ve noticed in line 2697 of the previously mentioned github link, they return generic event names, like CFireEvent is encoded as fireEvent
But on the Pull Request on the github you discovered, it looks like Fortahr wants to submit a new update that will correct the previously mentioned situation.
Fortahr (1 Hour ago)
Previous Emit/React versions merged, event names are now the same as the game event name itself, e.g.: “CEventShockingSeenNiceCar”.
I tested it on build 2545 but this should not be related. There has to be something (explosionEvent) blocking explosion damage. Does vehicle explosion, rpg, grenade explosions make damages on your server ?
Yes, every other explosion works fine. I’ve just disabled everything other than my script and it still doesn’t cause damage. Do you think that maybe because my script is a client script e.g. client.lua and not server.lua, that this would be an issue? The only thing in my code is what you suggested to try. That is the only thing I have running. The rest of FiveM is vanilla. I even tried the latest build.
How you got this to work is beyond me, I was reading a different thread and this issue was known / mentioned 7 months ago in June 2021.
I managed to create a work around for it though.
if Citizen.InvokeNative(0xE3AD2BDBAEE269AC, PlayerPos.x, PlayerPos.y-0.5, PlayerPos.z, 17, 0.9, 1, 0, 0.99, 0) then
SetPedConfigFlag(player,33,1) -- Sets Flag CPED_CONFIG_FLAG_DieWhenRagdoll if AddExplosion is invoked.
print(GetPedConfigFlag(player,33)) -- Returns the value of CPED_CONFIG_FLAG_DieWhenRagdoll.
end
Anyone else reading this thread, if you don’t want the character to die on ragDoll, just make the explosion to reduce health based on the distance to and from the explosion. You can figure it out.
SetEntityHealth(player,playerHealth-100) – Nearly Kills the player
NPCs are affected by it normally.
For other players on the server, it won’t cause damage. So you’ll need to generate a list of the nearest players, and then run that function for each player in the list.
Yep there’s no other way apparently, it seems that AddExplosion gives no damage in OneSync, unless it’s a AddOwnedExplosion owned by your own ped, most likely to prevent cheaters from exploiting it to kill everyone.