Jump to content

How to get RGB color from tocolor()?


Recommended Posts

Posted

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

Posted

No the problem is that tocolor() returns a decimal color with alpha, not a hexdecimal.

That means I need a function called decimaltoRGBA(string)

EDIT: Or much more simple, tocolor() reversed!

  • Moderators
Posted

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

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...