[lua]function Money_Save( ply )
local steamid = string.Replace(ply:SteamID(), “:”, “-”)
print(“Saving player “…ply:Nick()…”'s stats…”)
file.Write(“money/”…steamid…".txt", ply:Name()…"
“…ply:SteamID()…”
"…ply:GetNWInt(“Money”))
end[/lua]
To load it again just use something like this…
[lua]
function Money_Load( ply )
if ply:IsPlayer() then
local steamid = string.Replace(ply:SteamID(), “:”, “-”)
local contents = ‘’
if not file.Exists(“money/”…steamid…".txt") then
print(‘No data’)
Money_Save( ply )
else
print(‘Reading’)
contents = file.Read(“money/”…steamid…".txt")
local values = string.Explode("
", contents)
ply:SetNWString( “Money”, values[3] )
end
end
end
[/lua]
I’d recommend you use SQL rather than text files, it’s much more efficient.
KevKev’s code is better so use his. I prefer using separate text files though just for keeping shit organized.