CreateFireworks: Difference between revisions

From Onset Developer Wiki
28days (talk | contribs)
No edit summary
Justus (talk | contribs)
m Updated description
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Info|Function|Client|1.0}}
{{Info|Function|Client|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Creates fireworks that shoot upwards and explode. ModelId presets contain various shapes/styles of fireworks.}}


{{FuncSyntax|CreateFireworks(modelid, x, y, z, rx, ry, rz)}}
{{FuncSyntax|CreateFireworks(modelid, x, y, z, rx, ry, rz)}}
Line 19: Line 19:


== Example ==
== Example ==
__EDIT_ME__
'''Client:'''
<syntaxhighlight lang="Lua>
function ClientCreateFireworks(type)
local x, y, z = GetPlayerLocation()
CreateFireworks(type, x, y, z + 150, 90, 0, 0)
end
AddRemoteEvent("ClientCreateFireworks", ClientCreateFireworks)
</syntaxhighlight>
 
'''Server:'''
<syntaxhighlight lang="Lua>
function cmd_fireworks(player, type)
if (type == nil) then
return AddPlayerChat(player, "Usage: /fireworks <type 1-13>")
end
type = tonumber(type)
 
if (type < 0 or type > 13) then
return AddPlayerChat(player, "Parameter \"type\" 1-13")
end
 
CallRemoteEvent(player, "ClientCreateFireworks", type)
AddPlayerChat(player, "Fireworks created!")
end
AddCommand("fireworks", cmd_fireworks)
</syntaxhighlight>


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

Latest revision as of 19:25, 19 December 2019

CreateFireworks

Type: Function
Context: Client
Introduced: v1.0

Description

Creates fireworks that shoot upwards and explode. ModelId presets contain various shapes/styles of fireworks.

Syntax

CreateFireworks(modelid, x, y, z, rx, ry, rz)

Parameters

  • modelid
    Id for fireworks preset (1-13).
  • x
    World X location.
  • y
    World Y location.
  • z
    World Z location.
  • rx
    Pitch rotation. Should be 90.0 to have the fireworks shoot up.
  • ry
    Yaw rotation.
  • rz
    Roll rotation.

Return Value

  • Returns true on success.

Example

Client:

function ClientCreateFireworks(type)
	local x, y, z = GetPlayerLocation()
	CreateFireworks(type, x, y, z + 150, 90, 0, 0)
end
AddRemoteEvent("ClientCreateFireworks", ClientCreateFireworks)

Server:

function cmd_fireworks(player, type)
	if (type == nil) then
		return AddPlayerChat(player, "Usage: /fireworks <type 1-13>")
	end
	
	type = tonumber(type)

	if (type < 0 or type > 13) then
		return AddPlayerChat(player, "Parameter \"type\" 1-13")
	end

	CallRemoteEvent(player, "ClientCreateFireworks", type)
	AddPlayerChat(player, "Fireworks created!")
end
AddCommand("fireworks", cmd_fireworks)

See also