SA-MP Forums Archive
[HELP]I need help with a stock - 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: [HELP]I need help with a stock (/showthread.php?tid=531566)



[HELP]I need help with a stock - gami007 - 13.08.2014

sorry for my bad english :C

the question is that I have a problem with this stock


Код:
stock RGBA2(red, green, blue, alpha)
{
	return (red * 16777216) + (green * 65536) + (blue * 256) + alpha;
}
And the error I get is:
Код HTML:
C:\samp03z_svr_R1_win32\gamemodes\TheBlackScorpion2.pwn(16383) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
please helpme!! u.u


Re: [HELP]I need help with a stock - XStormiest - 13.08.2014

pawn Код:
stock RGBA2(red, green, blue, alpha)
{
             new rgb=(red * 16777216) + (green * 65536) + (blue * 256) + alpha;
    return rgb;
}
Hm... Im not so sure if this will work, it may be a problem if you used this, ... you see... this is a Integrer function, and what you try to do is a hex function, colors are in a hex format, you see.. 0x800000FF, that may be red, what your formula do is just returning a number;
Are you using this in a SendClientMessage function. like:

SendClientMessage(playerid, RGBA2(255, 0, 0, 80), "TEXT" );

The errors seems to not be from the function, it may be an incorect use of it, thats all i can see.
The thing that i do is just to see if this is a problem from direct returning, so i did that wich is actually the same thing in logic, but for the computer is a different thing

EDIT: It looks like SendClientMessage uses also an integrer for color parameter, so it may be from using your function incorrectly or if you can put the exact line of the error, maybe i can guess what your problem is


Re: [HELP]I need help with a stock - gami007 - 13.08.2014

Quote:
Originally Posted by XStormiest
Посмотреть сообщение
pawn Код:
stock RGBA2(red, green, blue, alpha)
{
             new rgb=(red * 16777216) + (green * 65536) + (blue * 256) + alpha;
    return rgb;
}
Hm... Im not so sure if this will work, it may be a problem if you used this, ... you see... this is a Integrer function, and what you try to do is a hex function, colors are in a hex format, you see.. 0x800000FF, that may be red, what your formula do is just returning a number;
Are you using this in a SendClientMessage function. like:

SendClientMessage(playerid, RGBA2(255, 0, 0, 80), "TEXT" );

The errors seems to not be from the function, it may be an incorect use of it, thats all i can see.
The thing that i do is just to see if this is a problem from direct returning, so i did that wich is actually the same thing in logic, but for the computer is a different thing

EDIT: It looks like SendClientMessage uses also an integrer for color parameter, so it may be from using your function incorrectly or if you can put the exact line of the error, maybe i can guess what your problem is
I'm taking the stock to the clan system, and this is where RGBA2 deals:
Код:
		if(!strcmp(tmp, "info", true))
		{
		    tmp2 = strtok(cmdtext, idx);
 			if(!strlen(tmp2)) return SendClientMessage(playerid, BLANCO, "Usa: /clan info [TAG]");
 			format(Archivo, sizeof Archivo, "Clanes/%s.ini", tmp2);
 			if(dini_Exists(Archivo))
 			{
				format(DLG_INFO_STR, sizeof DLG_INFO_STR, "> ID: %d\n", dini_Int(Archivo, "ID"));
				format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Color: %d\n", DLG_INFO_STR, dini_Int(Archivo, "Color"));
				format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Lнder: %s\n", DLG_INFO_STR, dini_Get(Archivo, "Lider"));
				format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Miembros: %d\n", DLG_INFO_STR, dini_Int(Archivo, "Miembros"));
				format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Asesinatos: %d\n", DLG_INFO_STR, dini_Int(Archivo, "Asesinatos"));
				format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Muertes: %d\n", DLG_INFO_STR, dini_Int(Archivo, "Muertes"));
				format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Ratio: %0.0f\n", DLG_INFO_STR, dini_Float(Archivo, "Ratio"));
				for(new d = 1; d < 21; d++)
				{
				    format(string, sizeof string, "Miembro_%d", d);
					format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Miembro %d: %s\n", DLG_INFO_STR, d, dini_Get(Archivo, string));
				}
				format(string, sizeof string, "Informaciуn '%s' [%s]", dini_Get(Archivo, "Nombre"), dini_Get(Archivo, "TAG"));
		    	ShowPlayerDialog(playerid, DLG_CLAN_INFO, DIALOG_STYLE_MSGBOX, string, DLG_INFO_STR, "Aceptar", "Cancelar");
        	} else return SendClientMessage(playerid, ROJO, "No existe ese clan");
        	return 1;
        }
		if(!strcmp(tmp, "color", true))
		{
		    if(EnClan[playerid] == false) return SendClientMessage(playerid, ROJO, "No tienes clan");
			if(CColor[playerid] == true) return SendClientMessage(playerid, ROJO, "Cierra primero el combinador de colores.");
			if(strcmp(dini_Get(Archivo, "Lider"), Nickname[playerid]) != 0)
				return SendClientMessage(playerid, ROJO, "Necesitas ser el creador del clan para poder cambiar el color");
		    tmp2 = strtok(cmdtext, idx);
		    longitud = strlen(tmp2);
		    if(!longitud) return SendClientMessage(playerid, BLANCO, "Usa: /clan color [Cуdigo Hexadecimal]");
			if(longitud > 10) return SendClientMessage(playerid, ROJO, "Demasiado grande");

		    new
				rojo[3] = "00",
				azul[3] = "00",
				verde[3] = "00",
				alfa[3],
				ColorC;

		    if(tmp2[0] == '#')
		    {
				if(!IsAHexNumber(tmp2[1])) return SendClientMessage(playerid, ROJO, "Formato incorrecto. Ejemplo: #FFFFFFFF");
		        format(rojo, sizeof rojo, "%c%c", tmp2[1], tmp2[2]);
		        format(verde, sizeof verde, "%c%c", tmp2[3], tmp2[4]);
		        format(azul, sizeof azul, "%c%c", tmp2[5], tmp2[6]);
				if(tmp2[7] != '\0')
					format(alfa, sizeof alfa, "%c%c", tmp2[7], tmp2[8]);
				else alfa = "FF";
			    ColorC = RGBA2(HexToInt(rojo), HexToInt(verde), HexToInt(azul), HexToInt(alfa));
		        format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
		    	dini_IntSet(Archivo, "Color", ColorC);
				for(new i = 0; i < MAX_PLAYERS; i++)
				{
				    if(IsPlayerConnected(i))
						if(Clan_ID[playerid] == Clan_ID[i])
							SetPlayerColor(i, ColorC);
				}
				format(string, sizeof string, "~y~~h~ Color seleccionado~n~~p~#%s%s%s%s", rojo, verde, azul, alfa);
				GameTextForPlayer(playerid, string, 3000, 4);
				return 1;
		    }
		    else if(tmp2[0] == '0' && tmp2[1] == 'x')
		    {
				if(!IsAHexNumber(tmp2[2])) return SendClientMessage(playerid, ROJO, "Formato incorrecto. Ejemplo: 0xFFFFFFFF");
		        format(rojo, sizeof rojo, "%c%c", tmp2[2], tmp2[3]);
		        format(verde, sizeof verde, "%c%c", tmp2[4], tmp2[5]);
		        format(azul, sizeof azul, "%c%c", tmp2[6], tmp2[7]);
				if(tmp2[8] != '\0')
					format(alfa, sizeof alfa, "%c%c", tmp2[8], tmp2[9]);
				else alfa = "FF";

			    ColorC = RGBA2(HexToInt(rojo), HexToInt(verde), HexToInt(azul), HexToInt(alfa));
		        format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
		    	dini_IntSet(Archivo, "Color", ColorC);
				for(new i = 0; i < MAX_PLAYERS; i++)
				{
				    if(IsPlayerConnected(i))
						if(Clan_ID[playerid] == Clan_ID[i])
							SetPlayerColor(i, ColorC);
				}
				format(string, sizeof string, "~y~~h~ Color seleccionado~n~~p~0x%s%s%s%s", rojo, verde, azul, alfa);
				GameTextForPlayer(playerid, string, 3000, 4);
				return 1;
		    }
		    if(IsAHexNumber(tmp2))
		    {
		        format(rojo, sizeof rojo, "%c%c", tmp2[0], tmp2[1]);
		        format(verde, sizeof verde, "%c%c", tmp2[2], tmp2[3]);
		        format(azul, sizeof azul, "%c%c", tmp2[4], tmp2[5]);
				if(tmp2[6] != '\0')
					format(alfa, sizeof alfa, "%c%c", tmp2[6], tmp2[7]);
				else alfa = "FF";
			    ColorC = RGBA2(HexToInt(rojo), HexToInt(verde), HexToInt(azul), HexToInt(alfa));
		        format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
		    	dini_IntSet(Archivo, "Color", ColorC);
				for(new i = 0; i < MAX_PLAYERS; i++)
				{
				    if(IsPlayerConnected(i))
						if(Clan_ID[playerid] == Clan_ID[i])
							SetPlayerColor(i, ColorC);
				}
				format(string, sizeof string, "~y~~h~ Color seleccionado~n~~p~%s%s%s%s", rojo, verde, azul, alfa);
				GameTextForPlayer(playerid, string, 3000, 4);
				return 1;
			} else return SendClientMessage(playerid, ROJO, "Formato incorrecto. Ejemplo: FFFFFFFF");
		}
        return 1;
	}
and this is what really happens when compiling
Код HTML:
C:\samp03z_svr_R1_win32\gamemodes\TheBlackScorpion2.pwn(7308) : warning 202: number of arguments does not match definition
C:\samp03z_svr_R1_win32\gamemodes\TheBlackScorpion2.pwn(7308) : warning 202: number of arguments does not match definition
C:\samp03z_svr_R1_win32\gamemodes\TheBlackScorpion2.pwn(7331) : warning 202: number of arguments does not match definition
C:\samp03z_svr_R1_win32\gamemodes\TheBlackScorpion2.pwn(7331) : warning 202: number of arguments does not match definition
C:\samp03z_svr_R1_win32\gamemodes\TheBlackScorpion2.pwn(7352) : warning 202: number of arguments does not match definition
C:\samp03z_svr_R1_win32\gamemodes\TheBlackScorpion2.pwn(7352) : warning 202: number of arguments does not match definition
C:\samp03z_svr_R1_win32\gamemodes\TheBlackScorpion2.pwn(16362) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
again sorry for the bad English, and I speak Spanish jijijijij xDDD


Re: [HELP]I need help with a stock - gami007 - 14.08.2014

Helpme Please!!!