Loading Color?
#1

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;
}
Reply
#2

A hex value isn't a string, so you don't need to use strval.
Reply
#3

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.
Reply
#4

Nothing, inserting them as an integer should work.
Reply
#5

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
Reply
#6



I'm retarded, please excuse my shit posting.
Reply
#7

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.
Reply
#8

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;
 }
Reply
#9

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?
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)