PDA

View Full Version : is it even possible?


KaleOtter
06/10/2011, 03:11 PM
Example:

new Hexcolor[26];
format(Hexcolor,26,"#33CC00");
SetPlayerColor(playerid,Hexcolor);
Is this even possible?
Because it only makes my name black...
Maybe stupid question but I get sick of this day, everything goes wrong...

park4bmx
06/10/2011, 03:17 PM
you do it like this


#define Hexcolor "{33CC00}"

SetPlayerColor(playerid,Hexcolor);

KaleOtter
06/10/2011, 03:18 PM
No, because it's for family's, and I want to be able to change the colors ingame.
I don't ask how else I can do it, but I just ask if this is even possible.

park4bmx
06/10/2011, 03:22 PM
in that case you can use numbers for a color which they will be stored as variable
and just used it like example im using this

GangZoneShowForAll(id,16711888);

this makes my gangzone to blue with abit of transparent in it
EDIT:
another example

new Color = GetPVarInt(playerid, "16711888");
SetPlayerColor(playerid,Color);

KaleOtter
06/10/2011, 03:24 PM
Uhm well I tested that too, but I gues that didn't work because I put the numbers inside a string, I'm going to try it again.

KaleOtter
06/10/2011, 03:29 PM
Thanks for the help, it works.

KaleOtter
06/10/2011, 03:38 PM
wierd, the decimal color codes doesn't get the color it should be I tried 10 different sites with hex en dec colors, but I gues that's a sa-mp bug.(again)

Pharrel
06/10/2011, 03:46 PM
use infernus pawn editor...he got a color picker

RR GG BB AA

just with numbers will be like...

99000000 = transparent red
00990000 = transparent green
00009900 = transparent blue
99009900 = transparent purple
99999900 = transparent grey
00999900 = transparent lightblue

transparent means that will not show the markers in map..if you want to show the markers just replace the last 00 for 99

Jeffry
06/10/2011, 04:29 PM
For your command this might be helpful:

http://wiki.sa-mp.com/wiki/Colors_List#Convert_string_to_value_with_pawn

IstuntmanI
06/10/2011, 04:34 PM
Use this function:
stock hexstr( string[ ] ) // Function by ******
{
new ret, val, i;
if( string[ 0 ] == '0' && ( string[ 1 ] == 'x' || string[ 1 ] == 'X' ) ) i = 2;

while( string[ i ] )
{
ret <<= 4;
val = string[ i ++ ] - '0';
if( val > 0x09 ) val -= 0x07;
if( val > 0x0F ) val -= 0x20;
if( val < 0x01 ) continue;
if( val < 0x10 ) ret += val;
}
return ret;
}
Use like this:
new Hexcolor[ 26 ];
format( Hexcolor, 26, "#33CC00" );
SetPlayerColor( playerid, hexstr( Hexcolor ) );

playbox12
06/10/2011, 04:49 PM
Also don't make it a string, I think this works correctly;

new color = 0x009Ab8AA; (put 0x instead of the # and AA at the end. It's untested and my mind is not completely with coding atm).

KaleOtter
07/10/2011, 09:25 AM
Use this function:
stock hexstr( string[ ] ) // Function by ******
{
new ret, val, i;
if( string[ 0 ] == '0' && ( string[ 1 ] == 'x' || string[ 1 ] == 'X' ) ) i = 2;

while( string[ i ] )
{
ret <<= 4;
val = string[ i ++ ] - '0';
if( val > 0x09 ) val -= 0x07;
if( val > 0x0F ) val -= 0x20;
if( val < 0x01 ) continue;
if( val < 0x10 ) ret += val;
}
return ret;
}
Use like this:
new Hexcolor[ 26 ];
format( Hexcolor, 26, "#33CC00" );
SetPlayerColor( playerid, hexstr( Hexcolor ) );

This doesn't work too, it gives my a blue name instead of a red one.
...

playbox12
07/10/2011, 09:33 AM
This doesn't work too, it gives my a blue name instead of a red one.
...

Why don't you just do what I said? Store the hex value in a integer.

new color = 0x009Ab8AA;

Jeffry
07/10/2011, 09:44 AM
Why don't you just do what I said? Store the hex value in a integer.
Because he wants to enter them by a command from ingame!


Take the first function from here: (Posted this before)
http://wiki.sa-mp.com/wiki/Colors_List#Convert_string_to_value_with_pawn

This works fine for me.

(Example: /mycolor 0xFF0000FF)

Jeffry 8)