createExplosion | Multi Theft Auto: Wiki Skip to content

createExplosion

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


Creates an explosion of a certain type at a specified point in the world. If creator is specified, the explosion will occur only in its dimension.

Syntax

bool createExplosion ( float x, float y, float z, int theType, [ bool makeSound = true, float camShake = -1.0, bool damaging = true ] )
Required Arguments
  • x: a float value that specifies the X world coordinate where the explosion is created at.
  • y: a float value that specifies the Y world coordinate where the explosion is created at.
  • z: a float value that specifies the Z world coordinate where the explosion is created at.
  • theType: a integer specifying the explosion type, see: Explosion types
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • makeSound (default: true): a boolean specifying whether the explosion should be heard or not.
  • camShake (default: -1.0): a float specifying the camera shake's intensity.
  • damaging (default: true): a boolean specifying whether the explosion should cause damage or not.

Returns

  • bool: value

true if the explosion was created. false if invalid parameters were passed.

Code Examples

client

Example 1:This code will create an explosion for the local player when they spawn.

function explosionOnSpawn ( )
-- get the spawned player's position
local pX, pY, pZ = getElementPosition ( source )
-- and create an explosion there
createExplosion ( pX, pY, pZ, 6 )
end
-- add this function as a handler for any player that spawns
addEventHandler ( "onClientPlayerSpawn", localPlayer, explosionOnSpawn )

See Also

Explosion Functions
  • createExplosion