Garry's Mod Wiki
Why basic?
This chatbox type can be considered basic because it merely acts a reskin of the default chatbox and doesn't actually have much in the way of user interaction. It's easier for sure and is perfect for someone who is trying to just spice up their chatbox without having to code a whole lot.
Getting started
Setting up
I wont teach you it from scratch but at point I am assuming you have a DFrame for the background, DTextEntry for entering chat, and a RichText for storing the previous chats. I would recommend that you do not make these panels global but instead store their references in a global table to minimize confliction.
Here is a basic run down of how this type of chat box works by Facepunch user PortalGod
- Hide default chatbox in GM:StartChat, display vgui chatbox instead
- Overwrite GM:OnPlayerChat and add any messages to vgui chatbox
- Use GM:ChatTextChanged to change the vgui text entry (doesn't even have to be a text entry)
Hiding the default
Garry's Mod has a handy function that makes it easy to hide the default chat box, you just return true in this function. This is one function you should override
You also want to hide the default chat
Adding messages
Now we are going to hook onto OnPlayerChat, despite what PortalGod's instructions were, and update our chatbox
Lastly we hook ChatTextChanged to update our DTextEntry since technically the user won't have it focused because this chatbox has limited interaction
Finishing
Summary
That about covers how the basic reskin of the default chatbox works. You dont actually allow the player to interact with the chatbox but give the illusion of doing so.
Advanced Chatboxes
This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.
Page content is automatically updated twice a day. Edits and history are not available.
Last Parsed: Loading...