How to let players choose their colors?
#1

I know that there are probably 100 posts asking how to let their players choose their colors, but mine's a little different. I know how to let a player choose from about 10 different colors, or even 100 if i want to sit there all day writing it out but I want to know this:

How can I let players choose there colors like this: /choosecolor [red:0-255] [blue:0-255] [green:0-255)

it's a lot more complicated to me... I know it can be done. After some research I found this out about pawno color codes:

____________________________
0xRRGGBBAA

RR is the red part of the color.
GG the green part.
BB the blue part.
AA is the alphavalue.
____________________________

So that makes it a little easier to understand.. anyway can someone help me out here please?
Reply
#2

This will probably help you. http://www.drpeterjones.com/colorcalc/ You would need to figure out how hexadecimal color codes work. Although this may not be possible. I'm not sure. Good luck.
Reply
#3

Thanks I'll look into that link. I know it's possible, I've been to a server that did that, but it's looking a loot more difficult than I thought... Oh well I'm not one to give up. If I find out how to do it I'll release it (unless I find someone that already did).

Thanks again
Reply
#4

I think I'm gonna try to make a rgb to hex converter in pawn. The only reason I don't think this would work is because I don't see how you could store a hex value. This will tell you how they are converted http://ezduz.com/rgb-to-hex.html
Reply
#5

hmm you could use format to formatthe RRGGBB codes into the hex code, and then use it to do SetPlayerColor(playerid, theformmatedcode)
This is a pretty cool idea, i may look into it myself ^^
Reply
#6

Ya, im a noob scripter.. so I think I know how to do this but by literally converting everything manually... so 255 * 255 * 255 = 16581375 different possible colors... see u in a very long time lol
Reply
#7

I finished making the function. I've tested it against other rgb to hex converters online and it works. Check it out. http://samp.pastebin.com/mc389038
Reply
#8

wow wow wow man i can't believe u did it. i tried to think about how to do it and it was way beyond me.. although I am fairly new.
Thanks man full credits will go to u in my script.
But i have a few questions about it:

in stock RGBToHex(RVal,GVal,BVal,dest[]), what is the dest?
also, does pawno natively understand hex colors? or would I have to get a converter for that too?
Reply
#9

The dest is the destination string. Just look at the example below the function. As for your other question, I don't know.
Reply
#10

It doesn't have to be in hex for it to work under SetPlayerColor, you can just use the standard decimal.

pawn Код:
ConvertColor(R,G,B,A)return (R*16777216)+(G*65536)+(B*256)+A;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)