Skip to content

Fix client-side createExplosion not triggering onClientExplosion event #4341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

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
)

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.

2 participants