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