CreateFire: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Fixed English and clarified explanation of size argument.)
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
[[Image:Fire.png|thumb|200px|Fire with default size (1.8)]]


Creates a patch of fire that will spread a bit and die out after a while.
Creates a patch of fire that will spread a bit and die out after a while. Because it's a client side only function, other players won't see it, so custom events or custom objects will be needed to make a fire visible to some players.


==Syntax==
==Syntax==
Line 8: Line 9:


===Required Arguments===
===Required Arguments===
*'''x, y, z:''' coordinates of the fire.
*'''x, y, z:''' the coordinates when the initial patch of fire will be created.


===Optional Arguments===
===Optional Arguments===
*'''size:''' the size of the initial fire.
*'''size:''' a float value indicating the size of the initial patch of fire, this value also affects the duration of how long the fire remains.


===Returns===
===Returns===
Returns ''true'' if successful, ''false'' otherwise. There can be a maximum of 60 active fires.
Returns ''true'' if successful, ''false'' if bad arguments were passed or the limit of active fires was reached. There can be a maximum of 60 active fires.


== Example ==
== Example ==


<section name="Client" class="client" show="true">
This example adds a /fire command, which creates a patch of fire in the position of the player that types it.
Example code for creating Fire.


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function burn(player, commandName, height)
local function burn(commandName, theSize)
   if height then
   if tonumber(theSize) then
      x, y, z = getPlayerPosition(player)
        local x, y, z = getElementPosition(getLocalPlayer())
      createFire(x, y, z, height)
        createFire(x, y, z, tonumber(theSize))
      outputChatBox("Burn motherfucker, buuuuurn >:]", player)
        outputChatBox("Burn, buuuuurn >:]")
  else
        outputChatBox("Syntax: /fire <size>")
   end
   end
end
end

Latest revision as of 01:53, 8 September 2021

Fire with default size (1.8)

Creates a patch of fire that will spread a bit and die out after a while. Because it's a client side only function, other players won't see it, so custom events or custom objects will be needed to make a fire visible to some players.

Syntax

bool createFire ( float x, float y, float z [, float size = 1.8 ] )

Required Arguments

  • x, y, z: the coordinates when the initial patch of fire will be created.

Optional Arguments

  • size: a float value indicating the size of the initial patch of fire, this value also affects the duration of how long the fire remains.

Returns

Returns true if successful, false if bad arguments were passed or the limit of active fires was reached. There can be a maximum of 60 active fires.

Example

This example adds a /fire command, which creates a patch of fire in the position of the player that types it.

local function burn(commandName, theSize)
   if tonumber(theSize) then
        local x, y, z = getElementPosition(getLocalPlayer())
        createFire(x, y, z, tonumber(theSize))
        outputChatBox("Burn, buuuuurn >:]")
   else
        outputChatBox("Syntax: /fire <size>")
   end
end
addCommandHandler("fire", burn)

See Also