FxAddBlood: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
 
[[Image:Fxblood.png|thumb|200px|Blood splatter]]
Creates a blood splatter particle effect.
Creates a blood splatter particle effect.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool fxAddBlood ( float posX, float posY, float posZ, float dirX, float dirY, float dirZ, [int count=1, float brightness=1.0] )
bool fxAddBlood ( float posX, float posY, float posZ, float dirX, float dirY, float dirZ [, int count = 1, float brightness = 1.0 ] )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[Effect]].addBlood}}


===Required Arguments===
===Required Arguments===
Line 20: Line 21:
==Example==  
==Example==  
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
Example of creating Blood on Player Damage.
This example creates blood effects when a player gets shot.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local rootElement = getRootElement()
function BloodonDamage( attacker, weapon, bodypart, loss )
local healthvalue = 25
   if loss > 25 then -- if the player loses more than 25 hp, then...
 
       local x, y, z = getElementPosition( source ) -- get player's position for adding blood
function BloodonDamage(attacker, weapon, bodypart , loss )
       local randombloodamount = math.random( 1, 3 ) -- random blood amount 1-3
   if loss > healthvalue then -- if the Player loose more than 25 Hp then...
       local x, y, z = getElementPosition(source) -- getting the Players Position for adding Blood on his Position
       local randombloodamount = math.random( 1, 3 ) -- rando blood amount 1-3
       fxAddBlood ( x, y, z-2, 0.00000, 0.00000, 0.00000, randombloodamount, 1 )
       fxAddBlood ( x, y, z-2, 0.00000, 0.00000, 0.00000, randombloodamount, 1 )
       -- This adds Blood on the Current Player Position
       -- this adds blood to player's current position
   end
   end
end
end
 
addEventHandler( "onClientPlayerDamage", root, BloodonDamage ) -- calls the function when a player loses hp
addEventHandler("OnClientPedDamage",rootElement, BloodonDamage) -- Keep everything visible with onClientRender.
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
Line 40: Line 37:
==See Also==
==See Also==
{{Client Effects functions}}
{{Client Effects functions}}
[[ru:FxAddBlood]]

Latest revision as of 10:01, 21 June 2019

Blood splatter

Creates a blood splatter particle effect.

Syntax

bool fxAddBlood ( float posX, float posY, float posZ, float dirX, float dirY, float dirZ [, int count = 1, float brightness = 1.0 ] )

OOP Syntax Help! I don't understand this!

Method: Effect.addBlood(...)


Required Arguments

  • posX, posY, posZ: the world coordinates where the effect originates.
  • dirX, dirY, dirZ: a direction vector indicating where the blood flies to.

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.

  • count: the number of flying droplets to create.
  • brightness: the brightness. Ranges from 0 (almost black) to 1 (normal color).

Example

Click to collapse [-]
Client

This example creates blood effects when a player gets shot.

function BloodonDamage( attacker, weapon, bodypart, loss )
   if loss > 25 then -- if the player loses more than 25 hp, then...
      local x, y, z = getElementPosition( source ) -- get player's position for adding blood
      local randombloodamount = math.random( 1, 3 ) -- random blood amount 1-3
      fxAddBlood ( x, y, z-2, 0.00000, 0.00000, 0.00000, randombloodamount, 1 )
      -- this adds blood to player's current position
   end
end
addEventHandler( "onClientPlayerDamage", root, BloodonDamage ) -- calls the function when a player loses hp

See Also