FxAddSparks: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Client function}} Creates a number sparks along a line. ==Syntax== <syntaxhighlight lang="lua"> bool fxAddSparks ( float posX, float posY, float posZ, float dirX, float dirY, float dirZ, [flo...)
 
mNo edit summary
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
 
[[Image:Fxsparks.png|thumb|200px|Sparks]]
Creates a number sparks along a line.
Creates a number of sparks originating from a point or along a line.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool fxAddSparks ( float posX, float posY, float posZ, float dirX, float dirY, float dirZ, [float force=1, int count=1, float acrossLineX=0, float acrossLineY=0, float acrossLineZ=0, bool blur=false, float spread=1, float life=1] )
bool fxAddSparks ( float posX, float posY, float posZ, float dirX, float dirY, float dirZ [, float force = 1.0, int count = 1,
                  float acrossLineX = 0.0, float acrossLineY = 0.0, float acrossLineZ = 0.0, bool blur = false, float spread = 1.0, float life = 1.0 ] )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[Effect]].addSparks}}


===Required Arguments===
===Required Arguments===
Line 14: Line 16:


===Optional Arguments===
===Optional Arguments===
{{OptionalArg}}
*'''force:''' speed factor: the higher this value, the faster and further the sparks fly.
*'''force:''' speed factor: the higher this value, the faster and further the sparks fly.
*'''count:''' the number of effects to create.
*'''count:''' the number of effects to create.
Line 20: Line 23:
*'''spread:''' determines how strongly the particles deviate from each other. With low values the particles will stay quite close together, high values will make them fly in all directions. Also affects their speed.
*'''spread:''' determines how strongly the particles deviate from each other. With low values the particles will stay quite close together, high values will make them fly in all directions. Also affects their speed.
*'''life:''' the higher this value, the longer the sparks survive before they disappear.
*'''life:''' the higher this value, the longer the sparks survive before they disappear.
===Returns===
Returns a true if the operation was successful, false otherwise.
==Example==
<section name="Client" class="client" show="true">
This example will add Fire Bins to all locations added in the table.
<syntaxhighlight lang="lua">
fires = {
    {0, 0, 3} --Middle of SA
}
for i = 1, #fires do
    bin = createObject(1362, fires[i][1], fires[i][2], fires[i][3]-0.5)
    torch = createObject(3461, fires[i][1]-0.1, fires[i][2]-0.1, fires[i][3]-2)
    light = createMarker(fires[i][1], fires[i][2], fires[i][3]+0.2, "corona", 1, 255, 170, 0, 80, root)
    fireCol = createColSphere(fires[i][1], fires[i][2], fires[i][3]+0.5, 0.8)
    setTimer(fxAddSparks, math.random(4000, 5000), 0, fires[i][1]+math.random(0.1, 0.3), fires[i][2]+math.random(0.1, 0.2), fires[i][3]+0.2, 1, 1, 1)       
           
    addEventHandler("onClientColShapeHit", fireCol,
    function(theElement)
        if (getElementType(theElement) == "player") then
            setPedOnFire(theElement, true)
        end
    end)
           
end
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Client Effects functions}}
{{Client Effects functions}}

Latest revision as of 09:59, 21 June 2019

Sparks

Creates a number of sparks originating from a point or along a line.

Syntax

bool fxAddSparks ( float posX, float posY, float posZ, float dirX, float dirY, float dirZ [, float force = 1.0, int count = 1,
                   float acrossLineX = 0.0, float acrossLineY = 0.0, float acrossLineZ = 0.0, bool blur = false, float spread = 1.0, float life = 1.0 ] )

OOP Syntax Help! I don't understand this!

Method: Effect.addSparks(...)


Required Arguments

  • posX, posY, posZ: the world coordinates where the sparks originate.
  • dirX, dirY, dirZ: a direction vector indicating where the sparks fly to. The longer this vector is, the faster the sparks fly.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • force: speed factor: the higher this value, the faster and further the sparks fly.
  • count: the number of effects to create.
  • acrossLineX, acrossLineY, acrossLineZ: a vector starting at the pos coordinates. If specified, the sparks will be created along a line going from pos to pos - acrossLine. If not specified, all sparks originate from the point at pos.
  • blur: if false, creates standard bullet impact-like sparks. If true, adds motion blur to the sparks.
  • spread: determines how strongly the particles deviate from each other. With low values the particles will stay quite close together, high values will make them fly in all directions. Also affects their speed.
  • life: the higher this value, the longer the sparks survive before they disappear.

Returns

Returns a true if the operation was successful, false otherwise.

Example

Click to collapse [-]
Client

This example will add Fire Bins to all locations added in the table.

fires = {
    {0, 0, 3} --Middle of SA
}


for i = 1, #fires do
    bin = createObject(1362, fires[i][1], fires[i][2], fires[i][3]-0.5)
    torch = createObject(3461, fires[i][1]-0.1, fires[i][2]-0.1, fires[i][3]-2)
    light = createMarker(fires[i][1], fires[i][2], fires[i][3]+0.2, "corona", 1, 255, 170, 0, 80, root)
    fireCol = createColSphere(fires[i][1], fires[i][2], fires[i][3]+0.5, 0.8)
    setTimer(fxAddSparks, math.random(4000, 5000), 0, fires[i][1]+math.random(0.1, 0.3), fires[i][2]+math.random(0.1, 0.2), fires[i][3]+0.2, 1, 1, 1)         
            
    addEventHandler("onClientColShapeHit", fireCol, 
    function(theElement)
        if (getElementType(theElement) == "player") then
            setPedOnFire(theElement, true)
        end
    end)
            
end

See Also