Jump to content

Chat Problem! (Simple Problem)


iRack

Recommended Posts

Hi! I have this code and I don't know how to make it to look like this : https://imgur.com/a/LZku5bk . My resource : https://imgur.com/a/RDaXnTk . I want that : when the private chat ( photo with red <<Inspector>> ) is with red, the time stamp will be with red or when I put an ad with color green , the time stamp will be green too. Code:

Quote

function theFormat()
    local realtime = getRealTime()
    return
    string.format("%02d:%02d:%02d", realtime.hour, realtime.minute, realtime.second)
end

function chattime(text, msgtype)
    local cTime = theFormat()
    local pName = getPlayerName(source)
if (msgtype == 0) then
    cancelEvent()
    outputChatBox("["..cTime.."] #FFFFFF"..pName..": #ebddb2"..text, getRootElement(), 255, 255, 255, true)
end
end
addEventHandler("onPlayerChat", root, chattime)
 

 

Link to comment

If someone type in the chat (T), the timestamp(timestamp is the [minutes:seconds]Player:<text>] it will be white. If someone type on a different chat like faction chat and that chat is blue, the timestamp will appear will the color blue. Another exemple, if i make a code with OutPutChatBox with #FF0000 (red), the timestamp will apear with the color red. Simple: the Color in chat will be exactly the timestamp color. 

Link to comment
  • Moderators
local function getFirstColorCode(text)
	local s, e = text:find("#%x%x%x%x%x%x")
	return (s and e) and text:sub(s, e) or "#FFFFFF"
end

local function getTimePrefix()
	local realtime = getRealTime()
    return "[" .. string.format("%02d:%02d:%02d", realtime.hour, realtime.minute, realtime.second) .. "] "
end

addEventHandler("onPlayerChat", root, function(text, msgtype)
	if msgtype == 0 then
		cancelEvent()
		local text = getPlayerName(source) .. ": #ebddb2" .. text
		outputChatBox(getFirstColorCode(text) .. getTimePrefix() .. text, root, 255, 255, 255, true)
	end
end)

 

Do you mean something like that?

  • Thanks 1
Link to comment

No, I have a resource which is blocking the players colors, all players have the color White at their nick. For every time of chat like this: https://imgur.com/a/4danWtz  Look at that guy [PREMIUM], that in premium chat [/pc] like [/a-chat admin] has before the tag a timestamp with the color green because the chat is made with that color. Or admin chat in this photo https://imgur.com/a/4danWtz . (2)Admin K... has a timestamp between him because is a different chat and the timestamp with another color. I don't know how to explain. This is my chat with your code : https://imgur.com/a/qKgGlCF Thanks for help 

Link to comment
  • Moderators

You want to show the timestamp before every line on the chat? (or I do not understand...)

This is my last tip.

 

This little script show the timestamp before EVERY(!) line on the chat.

-- CLIENT SIDE SCRIPT !!!

local function getFirstColorCode(text)
	local s, e = text:find("#%x%x%x%x%x%x")
	return (s and e) and text:sub(s, e) or "#FFFFFF"
end

local function getTimePrefix()
	local realtime = getRealTime()
    return "[" .. string.format("%02d:%02d:%02d", realtime.hour, realtime.minute, realtime.second) .. "] "
end

addEventHandler("onClientChatMessage", root, function(text, r, g, b)
	if not text:find("%d%d:%d%d:%d%d") then
		cancelEvent()
		outputChatBox(getFirstColorCode(text) .. getTimePrefix() .. text, r, g, b, true)
	end
end)

 

  • Thanks 1
Link to comment

,,You want to show the timestamp before every line on the chat? (or I do not understand...) "

exactly! Thanks for help! I will buy a script, because it is not working, I think it is a problem between 8 and 19 because it is not working all the script.Your was what I wanted. Thanks for help man! Have a nice day!

  • Like 1
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...