- Documentation
- Shared functions
- getColorFromString
Function
getColorFromString
Converts a colour code "#RRGGBB" or "#RRGGBBAA" (the # is optional) or a short "#RGB" / "#RGBA" (with #) into r, g, b, a components. Without an alpha channel it returns a = 255.
Syntax
int, int, int, int getColorFromString(string theColor)Arguments
theColorstring- The colour code.
Returns
r, g, b, a, or false when the text is not a colour code.
Example
addCommandHandler("kolor", function(player, _, code)
local r, g, b = getColorFromString(code or "")
if r then setPlayerNametagColor(player, r, g, b) end
end)