SA-MP Forums Archive
Transparent gang zone - 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: Transparent gang zone (/showthread.php?tid=590547)



Transparent gang zone - Rageparadise - 30.09.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;
}



AW: Transparent gang zone - Nero_3D - 30.09.2015

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));



Re: AW: Transparent gang zone - Rageparadise - 01.10.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:




AW: Transparent gang zone - Nero_3D - 01.10.2015

Well than you have no color saved inside Gang[gangid][GangColor] if it is black

You could simply test the code with that
pawn Код:
// setting red into GangColor, full alpha
Gang[gangid][GangColor] = 0xFF0000FF; // RED
// GangZone should be red transparent
GangZoneShowForAll(GangZone[zoneid][ZoneHolder], ((Gang[gangid][GangColor] & ~0xFF) | 0x50));
Guess something is wrong with your GangColor code


Re: Transparent gang zone - Crayder - 01.10.2015

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.


Re: Transparent gang zone - Rageparadise - 02.10.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.