Jump to content

How to get RGB color from tocolor()?


Recommended Posts

Well as you may now there is a function to convert a RGB colorcode to a hex number for the dxDrawText function.

But I need to now how to convert the hex NUMBER value back to RGB or to a normal hex value. GetColorFromString doesn't work for the tocolor() value.

I'm not experienced at formating string so could you give me a function to convert it?

Thanks and greets

Sniper

Link to comment
  • Moderators

I think you only can make a decimalToRGB and not decimalToRGBA:

You know that in HEXA, the syntax is #RRGGBB

you can use string.sub( "The string", start, end )

Exemple:

local something = string.sub("Hello MTA user", 3, 5) -- here [b]something[/b] = "llo" 

Now you can extract the R then the G the the B

Note: after 99, it's 9A, 9B, ... 9F, A0, A1, ... A9, AA, AB ... AF, B0, etc

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...