Posts: 23
Threads: 6
Joined: Jun 2015
So after capturing a zone, I have this code:
Код:
GangZoneStopFlashForAll(GangZone[zoneid][ZoneHolder]);
new colour[9];
format(colour, 9, "%s50", Gang[gangid][GangColor]);
GangZoneShowForAll(GangZone[zoneid][ZoneHolder], HexToInt(colour));
but it just goes transparent and no color is set for the zone.
hextoint stock:
Код:
stock HexToInt(string[]) // DracoBlue
{
if (string[0] == 0) return 0;
new i, cur=1, 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;
}
Posts: 23
Threads: 6
Joined: Jun 2015
Quote:
Originally Posted by Nero_3D
Well you used %s for a color, colors are normal integers, no need to use format, if you save the color in RGBA format this should work
Delete previous alpha with "& ~0xFF" and add the new alpha with "| 0x50"
pawn Код:
GangZoneStopFlashForAll(GangZone[zoneid][ZoneHolder]); GangZoneShowForAll(GangZone[zoneid][ZoneHolder], ((Gang[gangid][GangColor] & ~0xFF) | 0x50));
|
Hello, thanks for helping but this is what it looks like:
Posts: 3,324
Threads: 96
Joined: Sep 2013
Personal Opinion: Handling hex values using strings is useless! There is absolutely no point in doing that. If you want to try and prove me wrong go ahead, I have plenty of reasons against it.
You can manipulate hex values so much easier and cleaner with binary operations.
You can print them with as many leading zeros as you want like this (8 leading, even when the value is below 268435455, aka 0x0FFFFFFF, which would normally print like this: FFFFFFF): "printf("%8x", color);".
Quote:
Originally Posted by Scripter18
Find someone to help you with this or fix it by yourself
|
I just reported you. That is literally the most useless comment I've seen in like a week. No shit he is going to find someone, that's why he's in the fucking
HELP SECTION.
Posts: 23
Threads: 6
Joined: Jun 2015
Quote:
Originally Posted by Crayder
Personal Opinion: Handling hex values using strings is useless! There is absolutely no point in doing that. If you want to try and prove me wrong go ahead, I have plenty of reasons against it.
You can manipulate hex values so much easier and cleaner with binary operations.
You can print them with as many leading zeros as you want like this (8 leading, even when the value is below 268435455, aka 0x0FFFFFFF, which would normally print like this: FFFFFFF): "printf("%8x", color);".
I just reported you. That is literally the most useless comment I've seen in like a week. No shit he is going to find someone, that's why he's in the fucking HELP SECTION.
|
thank you, it's fixed now.