RGBA: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server & Client|1.0}} | {{Info|Function|Server & Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Converts RGBA to an integer. All values (including alpha) must be between 0 to 255. }} | ||
{{FuncSyntax|RGBA(r, g, b, a)}} | {{FuncSyntax|RGBA(r, g, b, a)}} | ||
Line 9: | Line 9: | ||
{{FuncParam|g|The green}} | {{FuncParam|g|The green}} | ||
{{FuncParam|b|The blue}} | {{FuncParam|b|The blue}} | ||
{{FuncParam|a|The | {{FuncParam|a|The alpha opacity}} | ||
{{FuncReturnValue|Returns the | {{FuncReturnValue|Returns the color as an integer.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | <syntaxhighlight lang="Lua"> | ||
AddCommand("colorv", function(playerid, red, green, blue, alpha) | AddCommand("colorv", function(playerid, red, green, blue, alpha) | ||
if red < 0 or red > 255 or green < 0 or green > | if red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 or alpha < 0 or alpha > 255 then | ||
AddPlayerChat(playerid, "Usage: /colorv <red> <green> <blue>") | AddPlayerChat(playerid, "Usage: /colorv <red> <green> <blue>") | ||
end | end | ||
Line 32: | Line 32: | ||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
* [[RGB]] | * [[RGB]] | ||
* [[HexToRGBA]] |
Latest revision as of 14:54, 24 August 2020
Description
Converts RGBA to an integer. All values (including alpha) must be between 0 to 255.
Syntax
RGBA(r, g, b, a)
Parameters
- r
The red - g
The green - b
The blue - a
The alpha opacity
Return Value
- Returns the color as an integer.
Example
AddCommand("colorv", function(playerid, red, green, blue, alpha)
if red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 or alpha < 0 or alpha > 255 then
AddPlayerChat(playerid, "Usage: /colorv <red> <green> <blue>")
end
local vehicleid = GetPlayerVehicle(playerid)
if vehicleid ~= 0 then
AddPlayerChat(playerid, "You must be in a vehicle...")
end
SetVehicleColor(vehicleid, RGBA(red, green, blue, alpha))
end)