OnExplosion: Difference between revisions
Jump to navigation
Jump to search
(Adjust information about source element.) |
|||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server event}} | {{Server event}} | ||
{{Added feature/item|1.6. | {{Added feature/item|1.6.1|1.6.0|21914|This event is triggered every time an explosion is created either by server-side [[createExplosion]], or when reported by [[player]].}} | ||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 9: | Line 9: | ||
*'''y:''' Y 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 | *'''z:''' Z coordinate of where the explosion was created | ||
*'''theType:''' the type of explosion created, | *'''theType:''' the type of explosion created, see: [[Explosion types]] | ||
==Source== | ==Source== | ||
The [[event system#Event source|source]] of this event is the [[player]] who notified server about explosion, or [[root]] if explosion was created without specifying creator in [[createExplosion]]. | The [[event system#Event source|source]] of this event is the [[player]] who notified server about explosion, or [[root]] if explosion was created server-side along without specifying creator in [[createExplosion]]. | ||
===Canceling=== | ===Canceling=== | ||
If this event is [[Event system #Canceling|canceled]], the explosion will not occur. | If this event is [[Event system #Canceling|canceled]], the explosion will not occur. | ||
==Example== | ==Example== | ||
This example outputs information about occuring explosion. | This example outputs information about occuring explosion. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local debugMsgLevel = 4 | |||
local debugMsgR = 255 | |||
local debugMsgG = 127 | |||
local debugMsgB = 0 | |||
local explosionTypes = { | local explosionTypes = { | ||
[0] = "Grenade", | [0] = "Grenade", | ||
Line 28: | Line 31: | ||
[5] = "Car Quick", | [5] = "Car Quick", | ||
[6] = "Boat", | [6] = "Boat", | ||
[7] = " | [7] = "Aircraft", | ||
[8] = "Mine", | [8] = "Mine", | ||
[9] = "Object", | [9] = "Object", | ||
Line 37: | Line 40: | ||
function onExplosion(explosionX, explosionY, explosionZ, explosionType) | function onExplosion(explosionX, explosionY, explosionZ, explosionType) | ||
local explosionPos = | local explosionPos = explosionX..", "..explosionY..", "..explosionZ | ||
local explosionTypeName = explosionTypes[explosionType] | local explosionTypeName = explosionTypes[explosionType] | ||
local explosionSource = inspect(source) | local explosionSource = inspect(source) | ||
local debugMsg = explosionTypeName.." explosion has occured at "..explosionPos.." (source: "..explosionSource..")" | |||
local debugMsg = | |||
outputDebugString(debugMsg, debugMsgLevel, debugMsgR, debugMsgG, debugMsgB) | outputDebugString(debugMsg, debugMsgLevel, debugMsgR, debugMsgG, debugMsgB) | ||
Line 51: | Line 49: | ||
addEventHandler("onExplosion", root, onExplosion) | addEventHandler("onExplosion", root, onExplosion) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Server events}} | {{See also/Server event|Server events}} |
Latest revision as of 14:09, 11 January 2024
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, see: Explosion types
Source
The source of this event is the player who notified server about explosion, or root if explosion was created server-side along without specifying creator in createExplosion.
Canceling
If this event is canceled, the explosion will not occur.
Example
This example outputs information about occuring explosion.
local debugMsgLevel = 4 local debugMsgR = 255 local debugMsgG = 127 local debugMsgB = 0 local explosionTypes = { [0] = "Grenade", [1] = "Molotov", [2] = "Rocket", [3] = "Rocket Weak", [4] = "Car", [5] = "Car Quick", [6] = "Boat", [7] = "Aircraft", [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..")" outputDebugString(debugMsg, debugMsgLevel, debugMsgR, debugMsgG, debugMsgB) end addEventHandler("onExplosion", root, onExplosion)
See Also
Server events
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled