SA-MP Forums Archive
Attached object colors - 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: Attached object colors (/showthread.php?tid=626622)



Attached object colors - GoldenLion - 17.01.2017

Hi, I'm creating a player object system. Everything is working well except the colors. If I set a color then it just makes the object invisible. This is what the OnDialogResponse for adding colors looks like:
Код:
		case DIALOG_PLAYER_OBJECT_COLOR:
		{
			new color, slot = PlayerInfo[playerid][pEditingObject];
			
			switch (listitem)
			{
				case 0: color = 0xFFFFFFFF;
				case 1: color = 0x000000FF;
				case 2: color = 0x999999FF;
				case 3: color = 0x663300FF;
				case 4: color = 0xFF0000FF;
				case 5: color = 0x990000FF;
				case 6: color = 0xFF9900FF;
				case 7: color = 0xFFFF00FF;
				case 8: color = 0x00CC00FF;
				case 9: color = 0x66FF00FF;
				case 10: color = 0x0099FFFF;
				case 11: color = 0x66CCFFFF;
				case 12: color = 0x000099FF;
				case 13: color = 0x00FFFFFF;
				case 14: color = 0xFF66FFFF;
				case 15: color = 0x3300FFFF;
			}
			for (new i; i < strlen(inputtext); i++) {
				tolower(inputtext[0]);
			}
			PlayerObjects[playerid][slot][ObjectColor] = color; //this is the most important part
			
			PlayerInfo[playerid][pEditingObject] = -1;
			ResetListedObjects(playerid);
			
			if (PlayerObjects[playerid][slot][ObjectWearing]) RefreshPlayerObject(playerid, slot);
			
			SendClientMessageEx(playerid, COLOR_YELLOW, "* You have set the color of your %s to %s.", GetPlayerObjectName(PlayerObjects[playerid][slot][ObjectModel]), inputtext);
		}
This is how I set the attached object:
Код:
RefreshPlayerObject(playerid, slot)
{
	if (IsPlayerAttachedObjectSlotUsed(playerid, PlayerObjects[playerid][slot][ObjectIndex])) RemovePlayerAttachedObject(playerid, PlayerObjects[playerid][slot][ObjectIndex]);
	
	if (PlayerObjects[playerid][slot][ObjectColor] != -1) //this part is with the colors
	{
		SetPlayerAttachedObject(playerid, PlayerObjects[playerid][slot][ObjectIndex], PlayerObjects[playerid][slot][ObjectModel], PlayerObjects[playerid][slot][ObjectBone], PlayerObjects[playerid][slot][ObjectPos][0], PlayerObjects[playerid][slot][ObjectPos][1], PlayerObjects[playerid][slot][ObjectPos][2], 
		PlayerObjects[playerid][slot][ObjectPos][3], PlayerObjects[playerid][slot][ObjectPos][4], PlayerObjects[playerid][slot][ObjectPos][5], PlayerObjects[playerid][slot][ObjectPos][6], PlayerObjects[playerid][slot][ObjectPos][7], PlayerObjects[playerid][slot][ObjectPos][8], 
		PlayerObjects[playerid][slot][ObjectColor], PlayerObjects[playerid][slot][ObjectColor]);
	}
	else
	{
		SetPlayerAttachedObject(playerid, PlayerObjects[playerid][slot][ObjectIndex], PlayerObjects[playerid][slot][ObjectModel], PlayerObjects[playerid][slot][ObjectBone], PlayerObjects[playerid][slot][ObjectPos][0], PlayerObjects[playerid][slot][ObjectPos][1], PlayerObjects[playerid][slot][ObjectPos][2], 
		PlayerObjects[playerid][slot][ObjectPos][3], PlayerObjects[playerid][slot][ObjectPos][4], PlayerObjects[playerid][slot][ObjectPos][5], PlayerObjects[playerid][slot][ObjectPos][6], PlayerObjects[playerid][slot][ObjectPos][7], PlayerObjects[playerid][slot][ObjectPos][8]);
	}
}
What's the problem? Everything else works: it saves and loads everything including the colors, but the colors are acting weird.


Re: Attached object colors - Vince - 17.01.2017

Material colors are ARGB, not RGBA. So any color that doesn't start with 0xFF will range from only partially opaque to completely invisible.


Re: Attached object colors - GoldenLion - 17.01.2017

Quote:
Originally Posted by Vince
Посмотреть сообщение
Material colors are ARGB, not RGBA. So any color that doesn't start with 0xFF will range from only partially opaque to completely invisible.
Thank you.