Data Storage for gamemode

When making a gamemode how would I go about storing player information (Money, items, Names, and stats etc etc) in a .txt file, and then have the gamemode recall that information later on.

NWFloat, NWString

Thanks, I’ll look those up


Well, The wiki really isn’t helping me, can someone explain these to me?


I suggest using file.Write, file.Read + GLON

file.Write( “path/file.txt”, glon.encode( { “table”, “with”, “data” } ) )
local data = glon.decode( file.Read( “path/file.txt” ) )

And there’s also always cookies on the client and persistent data on the server.

I know for PData it says shared, but in my experience, it doesn’t work on the client.

It doesn’t work on the client because then everyone could set their money to 9999. :3:

For saving important information about your clients Persistent data is the simplest way to go. And it’s a lot simpler then txt files.

Example :

hook.Add(“PlayerInitialSpawn”,“DataRetrieving”, function(ply)
if !ply:GetPData(“Money”) then ply:SetPData(“Money”,0) end
ply:SetNWInt(“Money”, ply:GetPData(“Money”) )

function ChangeMoney(ply,amount)
money = ply:GetNWInt(“Money”) + amount
ply:SetPData(“Money”, money)
ply:SetNWInt(“Money”, money)
ChangeMoney(Player, 100 )
ChangeMoney(Player, -30)
The spawn hook sets a networked value which is cheaper then asking the database each time we want to know how much the player has. From then on you can use ChangeMoney to add and remove money.


Thanks alot Crazy Quebec, you gave me examples, links, and made it really clear! and even told me how to utilize it! :downs: