ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. getColorFromString

Function

getColorFromString

Server and clientCollision shapesIdentical to MTA:SA

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)

See also