HexToRgb Shared function

From Gothic 2 Online: Wiki
Jump to navigation Jump to search

This function was added in version: 0.0.0

Calculates the r, g, b color model of the specified hex representation.

Syntax

table hexToRgb(string hex)

Required Arguments

  • hex: The representative of hexadecimal color.

Returns

  • table: The function returns table with three values of RGB color.

Example

Server-side:

local function joinHandler(pid)
{
	local hex = rgbToHex(255,255,0);
	local rgb = hexToRgb(hex);
	sendMessageToPlayer(pid,255,255,0,"Welcome to our server!");
	sendMessageToPlayer(pid,255,255,0,"Interesting fact: the hex color of this message is " + hex);
	sendMessageToPlayer(pid,255,255,0,"But the RGB color of this message is " + rgb.r + " " + rgb.g + " " + rgb.b);
}

addEventHandler("onPlayerJoin", joinHandler);

Client-side:

local function respawnHandler()
{
	local hex = rgbToHex(255,255,0);
	local rgb = hexToRgb(hex);
	print("Congratulations, you are spawned!");
	print("Did you know that the hex color of this message is " + hex + "?");
	print("What if I told you, that the RGB color of this message is " + rgb.r + " " + rgb.g + " " + rgb.b + "?");
}

addEventHandler("onRespawn", respawnHandler);

Related functions