/**
** Created by horr0rjkee
** Thanks for Alex(tracker) for ColorHexToRGB function! Wiki link: https://wiki.alliedmods.net/User_messages
** Date: 30 September 2017
*/
#if defined easy_hud_message
	#endinput
#endif
#define easy_hud_message

/**
 * Prints hud message to player
 *
 * @param client		Client index.
 * @param channel		Channel index (Only 1 channel can write message).
 * @param posx			Position x on monitor (-1.0 = center).
 * @param posy			Position y on monitor (-1.0 = center).
 * @param color1		First color in HEX.
 * @param color2		Second color in HEX.
 * @param effect		Effect index (0 is fade in/fade out; 1 is flickery credits; 2 is write out).
 * @param fadetime		FadeIn time.
 * @param fadeouttime	FadeOut time.
 * @param holdtime		Hold time.
 * @param fxtime		Effect time (Effect type 2 used)
 * @param message		Message
 * @param ...			Variable number of format parameters.
 * @return				1 or 0.	
 */
stock bool:SendHudMessage(client,channel=3,Float:posx=-1.0, Float:posy=-1.0,color1r=255,color1g=255,color1b=255,color1a=255,color2r=255,color2g=255,color2b=255,color2a=255,effect=0,Float:fadetime=1.0,Float:fadeouttime=1.0,Float:holdtime=1.5,Float:fxtime=5.0,const String:message[],any:...)
{
	if(client == 0 || !IsClientConnected(client) || effect < 0 || fadetime < 0.0 || fadeouttime < 0.0 || holdtime < 0.0 || fxtime < 0.0) return false;
	new String:buffer[256];
	SetGlobalTransTarget(client);
	VFormat(buffer, sizeof(buffer), message, 13);
	new Handle:hBf = StartMessageOne("HudMsg", client);
	BfWriteByte(hBf, channel); //channel
	BfWriteFloat(hBf, posx); // x ( -1 = center )
	BfWriteFloat(hBf, posy); // y ( -1 = center )
	// second color
	BfWriteByte(hBf, color1r); //r1
	BfWriteByte(hBf, color1g); //g1
	BfWriteByte(hBf, color1b); //b1
	BfWriteByte(hBf, color1a); //a1 // transparent?
	
	// init color
	BfWriteByte(hBf, color2r); //r2
	BfWriteByte(hBf, color2g); //g2
	BfWriteByte(hBf, color2b); //b2
	BfWriteByte(hBf, color2a); //a2
	BfWriteByte(hBf, effect); //effect (0 is fade in/fade out; 1 is flickery credits; 2 is write out)
	BfWriteFloat(hBf, fadetime); //fadeinTime (message fade in time - per character in effect 2)
	BfWriteFloat(hBf, fadeouttime); //fadeoutTime
	BfWriteFloat(hBf, holdtime); //holdtime
	BfWriteFloat(hBf, fxtime); //fxtime (effect type(2) used)
	BfWriteString(hBf, buffer); //Message
	EndMessage();
	return true;
}