Reading and setting colours? - 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: Reading and setting colours? (
/showthread.php?tid=65739)
Reading and setting colours? -
Norn - 15.02.2009
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?
Re: Reading and setting colours? -
rensfromrpas - 15.02.2009
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
Re: Reading and setting colours? -
Norn - 15.02.2009
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
|
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?
Re: Reading and setting colours? -
Nimphious - 15.02.2009
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
|
But I guess you don't want to make it an inc? you want it to load from somewhere in the scriptfiles?
Re: Reading and setting colours? -
AlExAlExAlEx - 15.02.2009
but what's the point ?
why not just
new x4e2434342 COLOR_RED
and just COLOR_RED it's the same thing..
Re: Reading and setting colours? -
Ycto - 15.02.2009
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.)
Re: Reading and setting colours? -
Backwardsman97 - 15.02.2009
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..
|
Re: Reading and setting colours? -
AlExAlExAlEx - 15.02.2009
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...
Re: Reading and setting colours? -
Norn - 15.02.2009
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;
}
Re: Reading and setting colours? -
Ycto - 15.02.2009
No problem!