Global Chat -- Chat with multiple gmod servers

As seen in key G-mod communities, you can now chat across multiple servers using this MySQL based script

This is a customizable addon using andyvincent’s MySQL module to transmit chat messages over multiple servers.

** Features: **
[li] Customizable refresh rate (how often to recieve new messages from the MySQL)
[/li][li] Customizable table deletion time (How often to purge the MySQL table of all messages, to reduce lag and large queries)
[/li][li] Anti-Flood (Or anti-spam) with a time setting
[/li][li] Countless other script traits and variables I could define as a feature ?
**This requires your own MySQL Database to use.
This will not work without the gm_mysql module ( **

:siren: This does


create a huge chat room with every server running it, nor does it replace normal chat. This is an optional global chat (Used by typing /g by default) used between either multiple servers you own, or between you and other G-mod servers of your choice :siren:
Extract the globalchat folder to garrysmod \ addons

Navigate to and open the globalchat \ lua \ autorun \ server \ chat.lua file. You need to edit the MySQL data to your database, and other variables as shown below:

– Variables –
local serverName = “Server X” --Name of the server to be displayed in the chat
local trigger = “/g” --Trigger to send the global chat
local antiflood = 30 --How often a client can send a global chat (0 to disable, NOT reccomended)

– MySQL Variables –
local host = “localhost” --Host address
local user = “username” --MySQL Username
local pass = “password” --MySQL Password
local database = “chat” --Database used to store the chat table
local port = 3306 --Port to connect to
local persistent = true --Use a persistant MySQL connection?
local updatetime = 30 --In Seconds, how often to get messages from the MySQL
local cleantime = 10 --In MINUTES, how often to delete all records from MySQL table (To prevent the table from growing too large)[/lua]
The table structure is found in the chat.lua file or here:

**Table structure **

** Screenshots **

  • Not too much to take a screenshot of…*

contrasting local to global chat



Current version: 1.0.1

[li] Version 1.0.1 Fixed messages not outputting when another server clears the table
[/li][li] Version 1.0 Fixed small problem with the substring not calculating for a longer trigger (More characters that is) 
[/li][li] Version 1.0 first release


I use MySQL as opposed to sockets to do the communication between servers for ease and expandability. Instead of having to edit the file in every server when adding another, the new server simply has to connect to the existing MySQL database. (And well, to be honest, I don’t know where to start with sockets)


**Please report any bugs here **


yay its finally here! it reminds me of war of the servers

1.0.1 Released (That was quick eh)

[li]Version 1.0.1 Fixed messages not outputting when another server clears the chat

See OP for download

Seems like it’d lag insanely.

Try making one with sockets, seems like it’d be more efficient.

Cool idea, although i wish it would work with css or even all Source games :stuck_out_tongue: Could you do it with microphones aswell?
Good job so far!

It only updates every x seconds (30 default), so it wouldn’t lag as if it was a constant query

I was actually thinking about making a socket version. I went with MySQL just to make it easier for the average person to use (If they can get MySQL working correctly that is)

I’ll work on making a socket version of this script.

Microphones would be a whole new ballgame.

And compatibility with all Source games might not be out of the question (TF2 and CS:S if nothing else, as these are the most popular)

Thanks, a socket version would be great.

I <3 you

Some screenshots (As if they were needed?)

Not really much else to take a screenshot of.

Awesome work.


Update: Still pretty much stuck at the gate for a socket version, Haven’t had much experience with sockets so don’t really know where to start. Anyone who could help with sockets, or how to use them, security factors that should be considered, etc, please feel free (And please do) contact me. My steam profile page is: , you should be able to add me through there.

Any other hints, suggestions or comments would be highly appreciated

It would be rather awesome if someone could explain how to set up a MySQL Database without having too much work.

Awesome idea!

you should instead have global chat hooked through an irc channel. So it can be more instant :D.

I use this on my 2 servers :slight_smile:

Works great!

I think i have see this addon on another server its ace.
I have been searching for ways to get garrysmod chat on to my website and then i found “Web Interface for GlobalChat” so i downloaded it and setup a database (i don’t know mysql lol) but i got the web interface working. I edited the lua files so the server knows the IP,user,pass and database.

I can’t get your addon to work :S

I don’t know if it is my bad luck the addon or gm_mysql.

please help

Hmm, sounds nice. I think there’s a plugin by FLOOR_MASTER that implements it via SourceMod - I’ll have to see which one is more efficient.

@suicide_bomb - I have done this server -> server chat with my Modified Fairy Addon, and found that if you do the sql connection per player, will cause mixed results lag wise.

If you think of it logically, the laggiest part of mysql is the initial connection.

Send Username
Send Password
Send Databasename
Send Table
Send query
Get Result

and if you are doing this per a player, even if on a timer, you can end up with 3 or 4 queries going off in a row, or even at same time… (And if this is using gdatabase, you need to make sure that the Database connection variable is unique, otherwise another players connection to db will fail if that variable name exists already.)

The way I got around this was to open 1 connection for the server, and just keep it open, and every 6 or 7 seconds, for each player, query to see if there are any messages for that specific player, if not, do nothing, if there is, send them the message.

Means that no matter how many players join, the queries are all going off at a fixed time, and there will never be more than one connection per server.

(My fairy network is slightly different, in that I have provided a MYSQL database as a central repository, for all users to use, accross all servers that the addon gets installed on.)

This would be great if it wasn’t deleted…can you post a mirror?