Reading and setting colours?
#1

I'm trying to load colours from file, i've tried loading it as a string but it doesn't work, when i set the colour it just goes pure black.
Loading from file works, i'm just not sure what attribute to load it with, string etc..

(0xFF6347AA)

How would i load it?
Reply
#2

Quote:
Originally Posted by Norn
I'm trying to load colours from file, i've tried loading it as a string but it doesn't work, when i set the colour it just goes pure black.
Loading from file works, i'm just not sure what attribute to load it with, string etc..

(0xFF6347AA)

How would i load it?
you could do it like me i'll put all colors in 1 include
and then i do
pawn Код:
#include <colors>
Reply
#3

Quote:
Originally Posted by [PERG
prolol ]
Quote:
Originally Posted by Norn
I'm trying to load colours from file, i've tried loading it as a string but it doesn't work, when i set the colour it just goes pure black.
Loading from file works, i'm just not sure what attribute to load it with, string etc..

(0xFF6347AA)

How would i load it?
you could do it like me i'll put all colors in 1 include
and then i do
pawn Код:
#include <colors>
I'm loading the colour from file and storing it as Color[playerid]; then SetPlayerColor(playerid,Color[playerid]);

I'm confused how your method would solve this issue?
Reply
#4

Quote:
Originally Posted by [PERG
prolol ]
Quote:
Originally Posted by Norn
I'm trying to load colours from file, i've tried loading it as a string but it doesn't work, when i set the colour it just goes pure black.
Loading from file works, i'm just not sure what attribute to load it with, string etc..

(0xFF6347AA)

How would i load it?
you could do it like me i'll put all colors in 1 include
and then i do
pawn Код:
#include <colors>
But I guess you don't want to make it an inc? you want it to load from somewhere in the scriptfiles?
Reply
#5

but what's the point ?
why not just
new x4e2434342 COLOR_RED

and just COLOR_RED it's the same thing..
Reply
#6

Hai,

Make sure that the Color[playerid] is a string, then use SetPlayerColor(playerid,HexToInt(Color[playerid]));
Search the forums for the HexToInt function (I think it's somewhere in a big include, with various useful functions.)
Reply
#7

Quote:
Originally Posted by AppLeAppLeAppLe(AlExAlExAlEx)
but what's the point ?
why not just
#define x4e2434342 COLOR_RED

and just COLOR_RED it's the same thing..
Reply
#8

Quote:
Originally Posted by backwardsman97
Quote:
Originally Posted by AppLeAppLeAppLe(AlExAlExAlEx)
but what's the point ?
why not just
#define x4e2434342 COLOR_RED

and just COLOR_RED it's the same thing..
it was a example...
Reply
#9

Quote:
Originally Posted by [SAP
Ycto ]
Hai,

Make sure that the Color[playerid] is a string, then use SetPlayerColor(playerid,HexToInt(Color[playerid]));
Search the forums for the HexToInt function (I think it's somewhere in a big include, with various useful functions.)
Cheers mate! Works perfectly.

Here's the function for people searching when they need it.

pawn Код:
stock HexToInt(string[]) {
 if (string[0]==0) return 0;
 new i;
 new cur=1;
 new res=0;
 for (i=strlen(string);i>0;i--) {
  if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10);
  cur=cur*16;
 }
 return res;
}
Reply
#10

No problem!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)