How to store colors in variable
#1

Hi guys,
I wan to store color in variable(like 0x80FF80FF etc)
I'm try thisit don't work)

1)
Код:
new color;
if(sscanf(inputtext, "d", color)) return SCM...
ClanInfo[CLAN_COLOR] = color;
2)
Код:
new color[25];
if(sscanf(inputtext, "s", color)) return SCM...
ClanInfo[CLAN_COLOR] = color;
I get error(in line ClanInfo...)
Quote:

must be assigned to an array

3)

Код:
new color;
if(sscanf(inputtext, "s", color)) return SCM...
ClanInfo[CLAN_COLOR] = color;
My server crash with this.


4)

Код:
new color[20];
if(sscanf(inputtext, "s[20]", color)) return SCM...
ClanInfo[CLAN_COLOR] = strval(color);
I don't have idea what to try...
Reply
#2

2)
Код:
new color[25];
if(sscanf(inputtext, "s", color)) return SCM...
ClanInfo[CLAN_COLOR] = color;
I get error(in line ClanInfo...)

What are you trying to do with that? ^
Reply
#3

Use X to define a Hexadecimal value.

PHP код:
new color;
sscanf(inputtext"x"color); 
https://sampwiki.blast.hk/wiki/Format
Reply
#4

where can i get color codes?
Reply
#5

Quote:
Originally Posted by GospodinX
Посмотреть сообщение
My server crash with this.

4)

Код:
new color[20];
if(sscanf(inputtext, "s[20]", color)) return SCM...
ClanInfo[CLAN_COLOR] = strval(color);
I don't have idea what to try...
strval(string) tries to convert a string number to normal number, like so: "20" (string) -> strval -> 20 (integer)

I guess you're trying to store colors in format like "red", "green", "blue", etc. and calling strval upon those values crashes the server. So, you actually need to make a function that will "translate" the input color string to appropriate hex code.
Reply
#6

It's better if you defined your colors so you can use it more than once later on instead of using it like that..
Here is an example of how to define a color:
Код:
#define COLOR_WHITE (0xFFFFFFFF)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)