SetSearchLightColor

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function sets the color of a searchlight element.

Syntax

nil setSearchLightColor ( searchlight theSearchLight, int color )

Required Arguments

  • theSearchLight: the searchlight to set the color of.
  • color: the color to apply, created using tocolor.
[[{{{image}}}|link=|]] Note: The alpha component is stored, but does not affect the searchlight's appearance.

Returns

This function does not return any values. Invalid arguments raise an error.

Example

This example creates an orange searchlight above the player.

addCommandHandler("orangelight", function()
    local x, y, z = getElementPosition(localPlayer)
    local searchLight = createSearchLight(x, y, z + 10, x, y, z, 0, 5)

    if not searchLight then
        return
    end

    setSearchLightColor(searchLight, tocolor(255, 128, 0))
    outputChatBox("Created an orange searchlight.")

    -- Remove the demonstration light after 10 seconds.
    setTimer(destroyElement, 10000, 1, searchLight)
end)

See also