SetBlipColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Link to the Romanian translation of this page added.)
 
(18 intermediate revisions by 10 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__
This function will let you change the color of a blip. This color is only applicable to the default blip icon. All other icons will ignore this.
{{Server client function}}
This function will let you change the color of a blip. This color is only applicable to the default blip icon ([[Image:Blipid0s.png|12px]], [[Image:Blipid0u.png|12px]] or [[Image:Blipid0d.png|12px]]). All other icons will ignore this.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool setBlipColor ( blip theBlip, int red, int green, int blue, int alpha )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool setBlipColor ( blip theBlip, int red, int green, int blue, int alpha )</syntaxhighlight>
 
{{OOP||[[blip]]:setColor||getBlipColor|}}
===Required Arguments===  
===Required Arguments===  
*'''theBlip:''' The blip who's color you wish to set.
*'''theBlip:''' The blip who's color you wish to set.
Line 10: Line 11:
*'''green:''' The amount of green in the blip's color (0 - 255).
*'''green:''' The amount of green in the blip's color (0 - 255).
*'''blue:''' The amount of blue in the blip's color (0 - 255).
*'''blue:''' The amount of blue in the blip's color (0 - 255).
*'''alpha:''' The amount of alpha in the blip's color (0 - 255).
*'''alpha:''' The amount of alpha in the blip's color (0 - 255).  Alpha decides transparancy where 255 is opaque and 0 is transparent.


===Returns===
===Returns===
Line 19: Line 20:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- Retrieve a table containing all the blips that exist
-- Retrieve a table containing all the blips that exist
blips = getElementsByType ( "blip" )
local blips = getElementsByType ( "blip" )
-- Loop through the list, storing the blip from the table in the variable blipValue
-- Loop through the list, storing the blip from the table in the variable blipValue
for blipKey, blipValue in blips do
for blipKey, blipValue in ipairs ( blips ) do
-- Retrieve the blip's colors into the variables red, green, blue and alpha
-- Retrieve the blip's colors into the variables red, green, blue and alpha
red, green, blue, alpha = getBlipColor ( blipValue )
local red, green, blue, alpha = getBlipColor ( blipValue )
-- If the blip's icon isn't white already
-- If the blip's icon isn't white already
if ( red ~= 255 or green ~= 255 or blue ~= 255 or alpha ~= 255 ) then
if ( red ~= 255 or green ~= 255 or blue ~= 255 or alpha ~= 255 ) then
Line 33: Line 34:


==See Also==
==See Also==
{{Blip_Functions}}
{{Blip_functions}}
 
[[hu:setBlipColor]]
[[RO:setBlipColor]]

Latest revision as of 19:39, 20 July 2019

This function will let you change the color of a blip. This color is only applicable to the default blip icon (Blipid0s.png, Blipid0u.png or Blipid0d.png). All other icons will ignore this.

Syntax

bool setBlipColor ( blip theBlip, int red, int green, int blue, int alpha )

OOP Syntax Help! I don't understand this!

Method: blip:setColor(...)
Counterpart: getBlipColor


Required Arguments

  • theBlip: The blip who's color you wish to set.
  • red: The amount of red in the blip's color (0 - 255).
  • green: The amount of green in the blip's color (0 - 255).
  • blue: The amount of blue in the blip's color (0 - 255).
  • alpha: The amount of alpha in the blip's color (0 - 255). Alpha decides transparancy where 255 is opaque and 0 is transparent.

Returns

Returns true if the blip's color was set successfully. Returns false if the blip passed to the function is invalid, or any of the colors are out of the valid range.

Example

This example will find all the blips that exist and set them all to white if they aren't white already.

-- Retrieve a table containing all the blips that exist
local blips = getElementsByType ( "blip" )
-- Loop through the list, storing the blip from the table in the variable blipValue
for blipKey, blipValue in ipairs ( blips ) do
	-- Retrieve the blip's colors into the variables red, green, blue and alpha
	local red, green, blue, alpha = getBlipColor ( blipValue )
	-- If the blip's icon isn't white already
	if ( red ~= 255 or green ~= 255 or blue ~= 255 or alpha ~= 255 ) then
		-- Set the blip's color to white
		setBlipColor ( blipValue, 255, 255, 255, 255 )
	end
end

See Also