-
Notifications
You must be signed in to change notification settings - Fork 1
Useful Functions tocolor
Matheus Lima edited this page Nov 13, 2020
·
3 revisions
This function retrieves the hex number of a specified color.
tocolor( r, g, b, a ) -- alpha is optionalReturns a single value representing the color.
tocolor = function( r, g, b, a )
local hexadecimal = '0x'
local a = a or 255
for key, value in pairs({r, g, b, a}) do
local hex = ''
while(value > 0)do
local index = math.fmod(value, 16) + 1
value = math.floor(value / 16)
hex = string.sub('0123456789ABCDEF', index, index) .. hex
end
if(string.len(hex) == 0)then
hex = '00'
elseif(string.len(hex) == 1)then
hex = '0' .. hex
end
hexadecimal = hexadecimal .. hex
end
return tonumber(hexadecimal)
endEvent.bind('onPlayerConnect', function( player )
player:msg( 'Welcome to the server ' .. player.name .. '!', tocolor(255,255,255) ) -- white
player:msg( 'Don't forget your password.', tocolor(255,0,0) ) -- red
end)