Loading Color? - 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)
+--- Thread: Loading Color? (
/showthread.php?tid=559659)
Loading Color? -
xAzKingx - 24.01.2015
How do you load this color from saved files?
I have 0xFFFFF000 and 0xFFF000FF saved in KingdomColor and KingdomFlagColor.
They are not loading. This is my loading thing.
Код:
public LoadFamilys()
{
new arrCoords[3][64];
new strFromFile2[256];
new File: file = fopen("LARP/Familys.cfg", io_read);
if (file)
{
new idx;
while (idx < sizeof(FamilyInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
FamilyInfo[idx][FamilyTaken] = strval(arrCoords[0]);
FamilyInfo[idx][FamilyColor] = strval(arrCoords[1]);
FamilyInfo[idx][FamilyFlagColor] = strval(arrCoords[2]);
idx++;
}
fclose(file);
}
return 1;
}
Re: Loading Color? -
Dignity - 24.01.2015
A hex value isn't a string, so you don't need to use strval.
Re: Loading Color? -
xAzKingx - 24.01.2015
Quote:
Originally Posted by Mionee
A hex value isn't a string, so you don't need to use strval.
|
I dont know what should i use instead lol never worked with colors.
Re: Loading Color? -
Dignity - 24.01.2015
Nothing, inserting them as an integer should work.
Re: Loading Color? -
xAzKingx - 24.01.2015
Quote:
Originally Posted by Mionee
Nothing, inserting them as an integer should work.
|
Im loading the color from a file, Aight? Unless it wont load. This FamilyInfo[id][FamilyColor] Would be 0 or 000000
So can you please show me how its done lol
Re: Loading Color? -
Dignity - 24.01.2015
I'm retarded, please excuse my shit posting.
Re: Loading Color? -
Write - 24.01.2015
You must save the color as an integer and load it as an integer and don't use the "x" parameter it's broken atm.
Re: Loading Color? -
TakeiT - 24.01.2015
Not made by me, but I used something like this for a SetObjectMaterialText script I made about a year ago.
pawn Код:
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: Loading Color? -
Write - 24.01.2015
Quote:
Originally Posted by TakeiT
Not made by me, but I used something like this for a SetObjectMaterialText script I made about a year ago.
pawn Код:
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; }
|
If he's loading it as an integer why would he want to convert the hex to the integer again?
Re: Loading Color? -
xAzKingx - 24.01.2015
like i have been saying, Color system is pain in ass lol
i tried this, but this aint working either
Edit: I tried this too
Quote:
public LoadFamilys()
{
new rgba[4], argb[4], color[4];
new arrCoords[4][64];
new strFromFile2[256];
new File: file = fopen("LARP/Familys.cfg", io_read);
if (file)
{
new idx;
while (idx < sizeof(FamilyInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
FamilyInfo[idx][FamilyTaken] = strval(arrCoords[0]);
color[idx] = HexToInt(arrCoords[1]);
rgba[idx] = (color[idx] << | 0xFF,
argb[idx] = color[idx] | (0xFF << 24);
FamilyInfo[idx][FamilyColor] = rgba[idx];
FamilyInfo[idx][FamilyFlagColor] = argb[idx];
//printf("Family:%d Taken: %d Name:%s MOTD:%s Leader:%s Members:%d SpawnX:%f SpawnY:%f SpawnZ:%f Int:%d",
//idx,FamilyInfo[idx][FamilyTaken],FamilyInfo[idx][FamilyName],FamilyInfo[idx][FamilyMOTD],FamilyInfo[idx][FamilyLeader],FamilyInfo[idx][FamilyMembers],FamilyInfo[idx][FamilySpawn][0],FamilyInfo[idx][FamilySpawn][1],FamilyInfo[idx][FamilySpawn][2],FamilyInfo[idx][FamilyInterior]);
idx++;
}
fclose(file);
}
return 1;
}
|
doesnt work either, Shows some random color.