Jump to content
  • 0

pomoc Attach object zmena farby


_HoMeR_

Dotaz

Popis problému:

Zdravím,

mám urobené, že sa mi načíta číslo farby a naformátujem si to v tvare 0x .....

Neustále mi to píše argument type mismatch

 

Chyby/varování kompilátoru a při běhu:

--

 

Kód:

 

format(string, sizeof(string), "0x%dFF", c_color_1[vehicleid]);


-> error riadok SetDynamicObjectMaterial(c_object1, 0, -1, "none", "none", string);

 

 

 

Dodatečné poznámky:

--

Link to comment
Share on other sites

1 odpověd na tuto otázku

Recommended Posts

  • 0

protoze parametr barvy je ocekavan jako integer (hex) a ty mu predavas string

format(string, sizeof(string), "FF%06X", c_color_1[vehicleid]);//%06X znamena ze to chces v hex a na 6 mist (doplnit nulama)
SetDynamicObjectMaterial(c_object1, 0, -1, "none", "none", HexToInt(string));

You MUST use ARGB color format, not RGBA like used in client messages etc

http://wiki.sa-mp.com/wiki/SetObjectMaterial

stock HexToInt(text[])
{
	new num;
	for(new i;text[i];i++)
	{
		switch(text[i])
		{
			case 'x','X': num = 0;
			case '0' .. '9': num = (num << 4) | (text[i] - '0');
			case 'a' .. 'f': num = (num << 4) | (text[i] - ('a' - 10));
			case 'A' .. 'F': num = (num << 4) | (text[i] - ('A' - 10));
		}
	}
	return num;
}
Edited by ATomas
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...