Skip to content

Conversation

@MohabCodeX
Copy link
Contributor

Fixed an issue where the onClientExplosion event (which is triggered every time an explosion is created on the client’s scene) wasn’t being triggered when using createExplosion on the client-side.

Client-side testing :

local explosionTypes = {
    [0] = "Grenade",
    [1] = "Molotov",
    [2] = "Rocket",
    [3] = "Car",
    [4] = "Quick Car",
    [5] = "Boat",
    [6] = "Helicopter",
    [7] = "Mine",
    [8] = "Object",
    [9] = "Tank Grenade",
    [10] = "Small",
    [11] = "Tear Gas",
    [12] = "Fire",
    [13] = "Unknown"
}


local testPos = Vector3(2007.00000, 1545.00000, 13.17003) -- Change to any position
local delay = 1500 
local current = 0

function triggerNextExplosion()
    if explosionTypes[current] then
        createExplosion(testPos.x, testPos.y, testPos.z, current, nil)
        outputChatBox("Testing explosion type: " .. current .. " (" .. explosionTypes[current] .. ")", 255, 200, 0)
        current = current + 1
        setTimer(triggerNextExplosion, delay, 1)
    else
        outputChatBox("Explosion type test finished.", 0, 255, 0)
    end
end

addCommandHandler("testexplosions", function()
    current = 0
    triggerNextExplosion()
end)


addEventHandler("onClientExplosion", root,
    function(x, y, z, theType, theVehicle)
        outputChatBox("[Client-side] Explosion detected at: " .. x .. ", " .. y .. ", " .. z, 255, 100, 100)
    end
)

@Dutchman101
Copy link
Member

Thanks for the PR and all addressed code reviews, @MohabCodeX

@Dutchman101 Dutchman101 merged commit 4cefa4d into multitheftauto:master Aug 12, 2025
7 checks passed
MTABot pushed a commit that referenced this pull request Aug 12, 2025
4cefa4d Fix client-side `createExplosion` not triggering `onClientExplosion` event (#4341)
@MohabCodeX MohabCodeX deleted the fix/explosion-trigger-clientside branch August 13, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants