That is the question.
Anyway, i’m making a ranking system for my admin mod and i don’t know whether to use glon or SQL for storing data.

I currently use SQL to store data for my administration mod. I honestly don’t like it. For me, it took too much work to get going, and when you want to change the format of the save tables, it requires extra work. I would use GLON, or serialize a table so owners can edit the data if they want.

GLON is the simplest method of storing tables, and supports a huge array of data. SQL is the harder method of storing tables but is the fastest when reading data. When GLON stores and loads information from a file, you are making hard drive reads and writes that are slow. GLON works solely on hard drive speed, while SQL reads mostly on RAM speed and writes on the hard drive speed. When Gmod loads up, the SQL tables for each side of the client/server spectrum load their databases into memory. This allows the script to read from the fastest hardware for reading data, your RAM. SQL only takes a single HDD load at the beginning and the rest runs from the RAM. When you run from GLON, you use both sides of the hard drive spectrum, read and write.

But really when you get down to it, the differences in speed are so little that it’s best to go with the easiest, GLON.

Hm, i tried GLON but i failed miserably and i’ve used sql in the past. So, i’m not sure.

Show what you tried, it isn’t all that hard.

This is my GLON code for my admin mod -
I was trying to get it to do - If the player had to rank, set his rank to guest on join. If he has a rank, don’t.

for k,v in ipairs(player.GetAll()) do
side = string.gsub(tostring(v:SteamID()),":","_")

hook.Add( “PlayerInitialSpawn”, “playerInitialSpawn”, function ( ply )
local playerdat = {}
if ( playerdat[ ply:SteamID( ) ] == nil ) then playerdat[ ply:SteamID( ) ] = { }; end
playerdat[ ply:SteamID( ) ][ ‘rank’ ] = “guest”;

end )

contents = file.Read( “dmoddata/”…side…".txt");
succ, ret = pcall( glon.decode, contents );
if succ then
playerdat = ret


I’m seeing a few things at first glance:

  1. Why are you adding the PlayerInitialSpawn hook in the loop? What you are doing is not going to work.
  2. Why are you extracting the first part of the SteamID instead of using the UniqueID?
  3. GLON is very capable of storing large tables, so why use a seperate file for each player?
  4. You’re first recreating playerdat and then check if a key in the empty table is nil? What?

Here’s an idea:

[lua]local playerData = {}

– Check if there’s a file with player info and if it can be decoded
if ( file.Exists( “dmoddata/playerinfo.txt” ) ) then
success, ret = pcall( glon.decode, file.Read( “dmoddata/playerinfo.txt” ) )
if ( success ) then
playerData = ret

– The first time a player joins, their player data needs to be loaded
hook.Add( “PlayerInitialSpawn”, “RankHook”, function( ply )
local uniqueID = ply:UniqueID()

if ( playerData[ uniqueID ] ) then
	-- Sample idea to store the rank
	ply.DMod_Rank = playerData[ uniqueID ][ "Rank" ]
	-- If there's no player data for this player yet, create it and save it
	playerData[ uniqueID ] = {}
	playerData[ uniqueID ][ "Rank" ] = "guest"
	file.Write( "dmoddata/playerinfo.txt", glon.encode( playerData ) )

end )[/lua]