SA-MP Forums Archive
Convert color to string and opposite - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Convert color to string and opposite (/showthread.php?tid=161232)



Convert color to string and opposite - ikey07 - 19.07.2010

Now I stared to work on new clear self made GM, but I already can't figure out, it is posibble convert string to color and opposite, like, you can adjust your chat color by type color by self.


Re: Convert color to string and opposite - Mystique - 19.07.2010

Well now it belongs on if you want to have a command like /chatcolour or just have a command with these params /talk [colour] [text]


Re: Convert color to string and opposite - ikey07 - 19.07.2010

I want use it in many ways:

Like SCM instead of SendClientMessage - saw this somewhere.
For chat where leader can change chat color by type /chatcolor 0x0..... and than thats color saving into a file as string and than I can make SendClientMessage(playerid,colorstring[],text);

something like that


Re: Convert color to string and opposite - Joe_ - 19.07.2010

If you understood a Hex you'd know that there's 4 values:

pawn Код:
0xRRGGBBAA
Red, Green, Blue, Alpha

What you should do is use sscanf:

pawn Код:
if(!sscanf(params, "ddd", r, g, b))
And you then have the values that the user imputted, for example:

Код:
/chatcolour 0 30 255
Then use the function (somewhere on the forums) RGBAToHex, which should convert it into Hex.

Then save the Hex to a file.


Re: Convert color to string and opposite - ikey07 - 19.07.2010

That I know, I just think is it posibble to store for example 0x000000FF into a file as for example Color[]

and than read from file as SendClientMessage(playerid,Color[] ?


If I use

/color 0x000000FF
tmp = strtok(....
SendClientMessage(playerid,tmp,"Hello world!");


Re: Convert color to string and opposite - Finn - 19.07.2010

Yes, just use sscanf for that.


Re: Convert color to string and opposite - ikey07 - 19.07.2010

Done, done and done thx , its really help me out, everything working well