SetPedOnFire: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
{{Server client function}}
{{Server client function}}
This function can be used to set a ped on fire or extinguish a fire on it.
This function can be used to set a ped on fire or extinguish a fire on it.
{{deprecated|setElementOnFire}}


==Syntax==  
==Syntax==  
Line 20: Line 22:
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler("onClientResourceStart", resourceRoot,
function setLocalPlayerOnFire()
     function ()
     local inWater = isElementInWater(localPlayer)
         setTimer(  function()
 
                        if isElementInWater(getLocalPlayer()) then
    if inWater then
                            setPedOnFire ( getLocalPlayer(), true )
         local notOnFire = not isPedOnFire(localPlayer)
                        end
 
                    end, 1000, 0)
        if notOnFire then
            setPedOnFire(localPlayer, true)
        end
     end
     end
    )  
end
setTimer(setLocalPlayerOnFire, 1000, 0)
</syntaxhighlight></section>
</syntaxhighlight></section>



Latest revision as of 03:04, 31 December 2024

This function can be used to set a ped on fire or extinguish a fire on it.


Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use setElementOnFire instead.


Syntax

bool setPedOnFire ( ped thePed, bool isOnFire )

OOP Syntax Help! I don't understand this!

Method: ped:setOnFire(...)
Variable: .onFire
Counterpart: isPedOnFire


Required Arguments

  • thePed: The ped that we want to set/unset
  • isOnFire: true to set the ped on fire, false to extinguish any fire on him

Returns

Returns true if successful, false otherwise

Example

This script will set player on fire when they fall into water.

Click to collapse [-]
Client
function setLocalPlayerOnFire()
    local inWater = isElementInWater(localPlayer)

    if inWater then
        local notOnFire = not isPedOnFire(localPlayer)

        if notOnFire then
            setPedOnFire(localPlayer, true)
        end
    end
end
setTimer(setLocalPlayerOnFire, 1000, 0)

See Also