RGBA: Difference between revisions

From Onset Developer Wiki
28days (talk | contribs)
No edit summary
28days (talk | contribs)
No edit summary
Line 16: Line 16:
<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 > 0 or blue < 0 or blue > 255 or alpha < 0 or alpha > 255 then
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

Revision as of 03:12, 17 November 2019

RGBA

Type: Function
Context: Server & Client
Introduced: v1.0

Description

Returns the RGBA hex from the RGBA integer.

Syntax

RGBA(r, g, b, a)

Parameters

  • r
    The red
  • g
    The green
  • b
    The blue
  • a
    The alphaopacity

Return Value

  • Returns the RGBA hex

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)

See also