OnExplosion

From Multi Theft Auto: Wiki
Revision as of 13:05, 30 July 2023 by Srslyyyy (talk | contribs) (Add onExplosion event (https://github.com/multitheftauto/mtasa-blue/pull/3130))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This event is triggered every time an explosion is created either by server-side createExplosion, or reported by player.

Parameters

float x, float y, float z, int theType
  • x: X coordinate of where the explosion was created
  • y: Y coordinate of where the explosion was created
  • z: Z coordinate of where the explosion was created
  • theType: the type of explosion created, values are:
    • 0: Grenade
    • 1: Molotov
    • 2: Rocket
    • 3: Rocket Weak
    • 4: Car
    • 5: Car Quick
    • 6: Boat
    • 7: Heli
    • 8: Mine
    • 9: Object
    • 10: Tank Grenade
    • 11: Small
    • 12: Tiny

Source

The source of this event is the player who notified server about explosion.

Canceling

If this event is canceled, the explosion will not occur.

Example

This example outputs information about occuring explosion.

local explosionTypes = {
	[0] = "Grenade",
	[1] = "Molotov",
	[2] = "Rocket",
	[3] = "Rocket Weak",
	[4] = "Car",
	[5] = "Car Quick",
	[6] = "Boat",
	[7] = "Heli",
	[8] = "Mine",
	[9] = "Object",
	[10] = "Tank Grenade",
	[11] = "Small",
	[12] = "Tiny",
}

function onExplosion(explosionX, explosionY, explosionZ, explosionType)
	local explosionPos = (explosionX..", "..explosionY..", "..explosionZ)
	local explosionTypeName = explosionTypes[explosionType]
	local explosionSource = inspect(source)

	local debugMsg = (explosionTypeName.." explosion has occured at "..explosionPos.." (source: "..explosionSource..")")
	local debugMsgLevel = 4
	local debugMsgR = 255
	local debugMsgG = 127
	local debugMsgB = 0

	outputDebugString(debugMsg, debugMsgLevel, debugMsgR, debugMsgG, debugMsgB)
end
addEventHandler("onExplosion", root, onExplosion)

See Also

Server events


Event functions