CreateExplosion: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Info|Function|Server|1.0}}
{{Info|Function|Server|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Creates an explosion at the specified coordinates.}}


{{FuncSyntax|CreateExplosion(explosionid, x, y, z [, dimension, soundExplosion, camShakeRadius, radialForce])}}
{{FuncSyntax|CreateExplosion(explosionid, x, y, z [, dimension, soundExplosion, camShakeRadius, radialForce, damageRadius])}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|explosionid|__EDIT_ME__}}
{{FuncParam|explosionid|The explosion id from 1-20.}}
{{FuncParam|x|__EDIT_ME__}}
{{FuncParam|x|The X axis}}
{{FuncParam|y|__EDIT_ME__}}
{{FuncParam|y|The Y axis}}
{{FuncParam|z |__EDIT_ME__}}
{{FuncParam|z |The Z axis}}
{{FuncParam|dimension |__EDIT_ME__}}
{{FuncParamOptional|dimension |The dimension identifier, defaults to 0}}
{{FuncParam|soundExplosion|__EDIT_ME__}}
{{FuncParamOptional|soundExplosion|Whether to enable explosion sounds, default: true}}
{{FuncParam|camShakeRadius|__EDIT_ME__}}
{{FuncParamOptional|camShakeRadius|The camera shake radius, default: 1000.0}}
{{FuncParamOptional|radialForce|__EDIT_ME__}}
{{FuncParamOptional|radialForce|The radial force of the explosion, default: 500000.0}}
{{FuncParamOptional|damageRadius|The radius in which this explosion causes damage to the player, default: 600.0}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|Returns '''true''' on success.}}


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua>
function cmd_burn(player, otherplayer)
if (PlayerData[player].admin < 2) then
return AddPlayerChat(player, "Insufficient permission")
end
 
if (otherplayer == nil) then
return AddPlayerChat(player, "Usage: /burn <player>")
end
 
otherplayer = tonumber(otherplayer)
 
if (not IsValidPlayer(otherplayer)) then
return AddPlayerChat(player, "Selected player does not exist")
end
 
local x, y, z = GetPlayerLocation(otherplayer)
CreateExplosion(9, x + 200.0, y + 8.0, z + 3.0, true, 1500.0, 1000000.0)
 
AddPlayerChat(player, "You have burnt "..GetPlayerName(otherplayer).."("..otherplayer..")")
end
AddCommand("burn", cmd_burn)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
*[[CreateExplosion]]
*[[CreateFireworks]]

Latest revision as of 17:00, 16 March 2020

CreateExplosion

Type: Function
Context: Server
Introduced: v1.0

Description

Creates an explosion at the specified coordinates.

Syntax

CreateExplosion(explosionid, x, y, z [, dimension, soundExplosion, camShakeRadius, radialForce, damageRadius])

Parameters

  • explosionid
    The explosion id from 1-20.
  • x
    The X axis
  • y
    The Y axis
  • z
    The Z axis
  • dimension (optional)
    The dimension identifier, defaults to 0
  • soundExplosion (optional)
    Whether to enable explosion sounds, default: true
  • camShakeRadius (optional)
    The camera shake radius, default: 1000.0
  • radialForce (optional)
    The radial force of the explosion, default: 500000.0
  • damageRadius (optional)
    The radius in which this explosion causes damage to the player, default: 600.0

Return Value

  • Returns true on success.

Example

function cmd_burn(player, otherplayer)
	if (PlayerData[player].admin < 2) then
		return AddPlayerChat(player, "Insufficient permission")
	end

	if (otherplayer == nil) then
		return AddPlayerChat(player, "Usage: /burn <player>")
	end

	otherplayer = tonumber(otherplayer)

	if (not IsValidPlayer(otherplayer)) then
		return AddPlayerChat(player, "Selected player does not exist")
	end

	local x, y, z = GetPlayerLocation(otherplayer)
	CreateExplosion(9, x + 200.0, y + 8.0, z + 3.0, true, 1500.0, 1000000.0)

	AddPlayerChat(player, "You have burnt "..GetPlayerName(otherplayer).."("..otherplayer..")")
end
AddCommand("burn", cmd_burn)

See also