Jump to content

outputChatBox


SkiZo

Recommended Posts

Hello, i need some help.. 
i made some edit in players tags.. 
outputChatBox("|SWAT| ["..Rank.."] #00ff00" .. getPlayerName ( source ) .. " #0000FF:#ffFFff " .. text, getRootElement(), 000, 128, 192, true )

well it's work actually 
but i have about 3 ranks .. let's say Sinour and Juniour .. 
Sniour is Yellow and the other Orange .. how can i change the color of "rank" without putting a #hexcolor before it ( because it will give one color ) 
Thanks :D

Link to comment
  • Moderators

If I understood it correctly, you can use a table with the ranks as key and the rank color in their value:

local ranksColor = {
	["Sinour"] = "#f5dd42Sinour",
	["Juniour"] = "#f59b42Juniour"
}

So, try this:


local ranksColor = {
	["Sinour"] = "#f5dd42Sinour",
	["Juniour"] = "#f59b42Juniour"
}

-- to keep the the default text color you set
local oTextColor = RGBToHex(0, 128, 192) or "#ffffff"

outputChatBox("|SWAT| ["..(ranksColor[Rank] or "nil") .. oTextColor .."] #00ff00" .. getPlayerName ( source ) .. " #0000FF:#ffFFff " .. text, getRootElement(), 0, 128, 192, true )

-- wiki.multitheftauto.com/wiki/RGBToHex
function RGBToHex(red, green, blue, alpha)
	
	-- Make sure RGB values passed to this function are correct
	if( ( red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 ) or ( alpha and ( alpha < 0 or alpha > 255 ) ) ) then
		return nil
	end

	-- Alpha check
	if alpha then
		return string.format("#%.2X%.2X%.2X%.2X", red, green, blue, alpha)
	else
		return string.format("#%.2X%.2X%.2X", red, green, blue)
	end

end

 

Edited by DNL291
  • Like 1
Link to comment
5 hours ago, DNL291 said:

If I understood it correctly, you can use a table with the ranks as key and the rank color in their value:


local ranksColor = {
	["Sinour"] = "#f5dd42Sinour",
	["Juniour"] = "#f59b42Juniour"
}

So, try this:


local ranksColor = {
	["Sinour"] = "#f5dd42Sinour",
	["Juniour"] = "#f59b42Juniour"
}

-- to keep the the default text color you set
local oTextColor = RGBToHex(0, 128, 192) or "#ffffff"

outputChatBox("|SWAT| ["..(ranksColor[Rank] or "nil") .. oTextColor .."] #00ff00" .. getPlayerName ( source ) .. " #0000FF:#ffFFff " .. text, getRootElement(), 0, 128, 192, true )

-- wiki.multitheftauto.com/wiki/RGBToHex
function RGBToHex(red, green, blue, alpha)
	
	-- Make sure RGB values passed to this function are correct
	if( ( red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 ) or ( alpha and ( alpha < 0 or alpha > 255 ) ) ) then
		return nil
	end

	-- Alpha check
	if alpha then
		return string.format("#%.2X%.2X%.2X%.2X", red, green, blue, alpha)
	else
		return string.format("#%.2X%.2X%.2X", red, green, blue)
	end

end

 

Thank You That Worked ❤️ 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...