SetElementOnFire: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ {{Shared function}} {{New feature/item|3.0161|1.6.0|22864| This function can be used to set a element on fire or extinguish a fire on it. Supported types are ped, vehicle and object.}} ==Syntax== <syntaxhighlight lang="lua"> bool setElementOnFire ( element theElement, bool isOnFire ) </syntaxhighlight> {{OOP||element:setOnFire|onFire|isElementOnFire}} ===Required Arguments=== *'''theElement:''' The element that we want to set/unset....") |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 3: | Line 3: | ||
{{New feature/item|3.0161|1.6.0|22864| | {{New feature/item|3.0161|1.6.0|22864| | ||
This function can be used to set a [[element]] on fire or extinguish a fire on it. Supported types are [[ped]], [[vehicle]] and [[object]].}} | This function can be used to set a [[element]] on fire or extinguish a fire on it. Supported types are [[ped]], [[vehicle]] and [[object]].}} | ||
{{Note|Function on the client side only works on elements created on the client side.}} | |||
==Syntax== | ==Syntax== | ||
Line 17: | Line 19: | ||
Returns ''true'' if successful, ''false'' otherwise | Returns ''true'' if successful, ''false'' otherwise | ||
==Example== | ==Examples== | ||
<section name="Server" class="server" show="true"> | |||
'''Example 1:''' This example defines a command handler for the command ''fireelement''. This will fire up a player or their vehicle if the state is true. Otherwise the fire will be gone. | |||
<syntaxhighlight lang="lua"> | |||
local stringToBoolean = { | |||
["true"] = true, | |||
["false"] = false | |||
} | |||
addCommandHandler("fireelement", | |||
function(sourcePlayer, commandName, fireState) | |||
-- if the player didn't complete the command. | |||
if not (fireState) then | |||
local text = string.format("[Usage]: #FFFFFF/%s [%s]", commandName, "State") | |||
return outputChatBox(text, sourcePlayer, 255, 100, 100, true) | |||
end | |||
-- the state will automatically be a string so we change it to boolean. | |||
local fireState = stringToBoolean[fireState] | |||
-- if the state isn't boolean then we return it. | |||
if type(fireState) ~= "boolean" then | |||
return outputChatBox("[Error]: #FFFFFFThe state has to be true or false.", sourcePlayer, 255, 100, 100, true) | |||
end | |||
local playerVehicle = getPedOccupiedVehicle(sourcePlayer) | |||
if playerVehicle then -- if the player is in a vehicle | |||
setElementOnFire(playerVehicle, fireState) | |||
else -- if the player is not in a vehicle | |||
setElementOnFire(sourcePlayer, fireState) | |||
end | |||
end, false, false | |||
) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{ | {{Element functions}} |
Latest revision as of 18:21, 9 January 2025
Syntax
bool setElementOnFire ( element theElement, bool isOnFire )
OOP Syntax Help! I don't understand this!
- Method: element:setOnFire(...)
- Variable: .onFire
- Counterpart: isElementOnFire
Required Arguments
- theElement: The element that we want to set/unset.
- isOnFire: true to set the element on fire, false to extinguish any fire on it.
Returns
Returns true if successful, false otherwise
Examples
Click to collapse [-]
ServerExample 1: This example defines a command handler for the command fireelement. This will fire up a player or their vehicle if the state is true. Otherwise the fire will be gone.
local stringToBoolean = { ["true"] = true, ["false"] = false } addCommandHandler("fireelement", function(sourcePlayer, commandName, fireState) -- if the player didn't complete the command. if not (fireState) then local text = string.format("[Usage]: #FFFFFF/%s [%s]", commandName, "State") return outputChatBox(text, sourcePlayer, 255, 100, 100, true) end -- the state will automatically be a string so we change it to boolean. local fireState = stringToBoolean[fireState] -- if the state isn't boolean then we return it. if type(fireState) ~= "boolean" then return outputChatBox("[Error]: #FFFFFFThe state has to be true or false.", sourcePlayer, 255, 100, 100, true) end local playerVehicle = getPedOccupiedVehicle(sourcePlayer) if playerVehicle then -- if the player is in a vehicle setElementOnFire(playerVehicle, fireState) else -- if the player is not in a vehicle setElementOnFire(sourcePlayer, fireState) end end, false, false )
See Also
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement