Jump to content

help me


Recommended Posts

local mySerial = "SerialAdmin"

addEventHandler("onPlayerChat", root,
	function ( message, messageType )
		if ( messageType == 2 ) then
			for i,v in ipairs ( getElementsByType( "player" ) ) do
				if ( getPlayerSerial ( v ) == mySerial ) then
					local TeamName = getTeamName ( getPlayerTeam(source) )
					local r, g, b = getTeamColor ( getPlayerTeam(source) )
					outputChatBox("("..TeamName..") "..getPlayerName(source)..":#FFFFFF "..message.."",v,r,g,b)
				end
			end
		end
	end
)

color of messege don't show white why? this show #fffff with message

Link to comment

Color codes do not get translated because you have not enabled them. In order to enable color codes, you need to pass another argument (bool), which is true.

bool outputChatBox ( string text [, element visibleTo = getRootElement(), int r = 231, int g = 217, int b = 176, bool colorCoded = false ] )

Take a look at the bool colorCoded, that's what's missing from your code, so we simply do this:

outputChatBox("("..TeamName..") "..getPlayerName(source)..":#FFFFFF "..message.."",v,r,g,b, true) -- notice true here? that was missing from your code

replace the outputChatBox line of code with this one, you should be able to see color coded text.

Edited by Saml1er
Link to comment
local mySerial = "24269FEB647A6735C0752A9C13211E52"

addEventHandler("onPlayerChat", root,
	function ( message, messageType )
		if ( messageType == 2 ) then
			for i,v in ipairs ( getElementsByType( "player" ) ) do
				if ( getPlayerSerial ( v ) == mySerial ) then
					local TeamName = getTeamName ( getPlayerTeam(source) )
					local r, g, b = getTeamColor ( getPlayerTeam(source) )
					outputChatBox("("..TeamName..") "..getPlayerName(source)..":#FFFFFF "..message.."",v,r,g,b,true)
				end
			end
		end
	end
)

code true , but color message like color team lol

Link to comment
14 minutes ago, Abdulelah said:

code true , but color message like color team lol

can you please rephrase what you said? Also, when you output the message, if you don't want to do something else with the player then break the loop, like this:

if ( getPlayerSerial ( v ) == mySerial ) then
    local TeamName = getTeamName ( getPlayerTeam(source) )
    local r, g, b = getTeamColor ( getPlayerTeam(source) )
    outputChatBox("("..TeamName..") "..getPlayerName(source)..":#FFFFFF "..message.."",v,r,g,b,true)
    break -- this will break the loop
end

 

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...