Customize chat box !

Ok so, I’m back on,
I’m now making some better display for my gamemode, and I have questions about how the chat work.

I know it’s C++, but due to the fact Garry has not gave any C++ code for his chat box, I need your help.
Can I use PlayerBindPress to return true and block the message mod for being opened, then call my derma function ?
In my derma function, how can I do to make the player send a massage ?
How can I get the message list ?

Is there any hook, any way (even using direct render : no derma), to just remake the chat box render ?
Only thing I want to do is redraw the chat box nothing more…

In the hope of a quick answer,
Yuri6037

  1. Yes you can block with PlayerBindPress
  2. You run the say console command on the player
  3. You cannot get the previous messages from other servers

I am not sure why you want to re-render the chatbox, maybe elaborate a little?

Thank you ! But how can I get a list of every messages of the current connecter server (my server) as a table client side ?

[editline]31st August 2014[/editline]

PS : how can I make the messages that come when you haven’t opened the chat box to be rendered only if a a boolean is true ?

OnPlayerChat is called clientside when a message gets sent from the server to all clients. PlayerSay is serverside.

BUT, to replace the chat box, you wouldn’t be using those hooks unless you specifically called them by networking text to the server call PlayerSay, then have that networked to clients and specifically called OnPlayerChat to the client in the net message.

To replace the chat box, look at the base game-mode ( you’ll need to create everything, including the table to store the messages, removing messages if you want to store only x amount, so data management, then you’ll need to create the elements the client interacts with and so on ):


--[[---------------------------------------------------------
   Name: gamemode:StartChat( teamsay )
   Desc: Start Chat.
   
		 If you want to display your chat shit different here's what you'd do:
			In StartChat show your text box and return true to hide the default
			Update the text in your box with the text passed to ChatTextChanged
			Close and clear your text box when FinishChat is called.
			Return true in ChatText to not show the default chat text
			
-----------------------------------------------------------]]
function GM:StartChat( teamsay )
	return false
end

--[[---------------------------------------------------------
   Name: gamemode:FinishChat()
-----------------------------------------------------------]]
function GM:FinishChat()
end

--[[---------------------------------------------------------
   Name: gamemode:ChatTextChanged( text)
-----------------------------------------------------------]]
function GM:ChatTextChanged( text )
end


--[[---------------------------------------------------------
   Name: ChatText
   Allows override of the chat text
-----------------------------------------------------------]]
function GM:ChatText( playerindex, playername, text, filter )

	if ( filter == "chat" ) then
		Msg( playername, ": ", text, "
" )
	else
		Msg( text, "
" )
	end
	
	return false

end

ChatTextChanged should be called any time the chat contents change ( when the user types, so hook that to your DTextEntry OnChanged function ), the others should be self-described or described by the comment above. There may be a few others such as mentioned above the code.

Thank you very much ! The base of my chat system is already made from scratch :
User use say console command
Server receives PlayerSay
Server cancels everything related to source engine
Server calls RealisticRoleplay command interpretor
If interpretor returns false then it’s not a command : send message to all player that are near to the chatter
If interpretor returns true cancel player send message, then call the command function

As you can see everything is already setted up. Only the client isn’t stocking messages because I send these messages using a chat.Add witch is Client side SourceEngine related.

The only thing I need help now, is simple, really, but I don’t know how to do it : you know, when a player open chat, it animates (his hand is next to hear), how is this performed ? Is it SourceEngine related ? Is it possible to animate player arms ? If so, how ?

[editline]1st September 2014[/editline]

I will also try to use what you said just to see if this works better…

Check put the way TTT does this, although I have no idea if it’s optimized or anything.

Or you could try using the Lua Animations API

don’t use chat.Add. Have a clientside table for storing chat messages and use a table.insert called by net message to receive chat messages

Ok, but I have one problem… I would like to delete the chat.add call ; but how can you make a colored text to appear like source engine and make it disappear tick by tick… I never found any way to make these type of animations without using instances (so not lua bu c++ or Java).

Anyway, thanks for your info. I have a last question : how can you block user from accessing ingame menu ? Well, I don’t want to block this every time, but only when you’re using my chat box. Is there anyway to block it ?