help with writing to text file.

im wondering how i will get it to read the players steam ID and everything else from a .txt file.

basically what i want is a function where, when the player joins, it finds their steam ID from a text file and everything else on the same line in the text file.

so if it were to save somebody’s steam ID and kills on the same line of a file called kills.txt
how would i get it to read both of those and retrieve both those things as seperate variables?

thanks i know this is probably complicated

You could try something like this:

[lua]-- To make this all happen, we’re going to use a thing called GLON.
– GLON (Garry’s Mod Object Notation) is a way of storing tables as strings.

– Make the file if it doesn’t exist
if not file.Exists(“kills.txt”) then file.Write(“kills.txt”,glon.encode({})) end

– Write a player’s kills to a file
local function SaveKills(ply)

-- We use glon to decode the text from the kills.txt file
local data = glon.decode(file.Read("kills.txt"))

-- To store the data, the player's steamID is the key, and the kills is the value
data[ply:SteamID()] = ply:Frags()

-- You write the file after encoding the data with glon
file.Write("kills.txt",glon.encode(data))

end

– Get the kills a player has saved
local function GetKills(ply)

-- We use glon to decode the text from the kills.txt file
local data = glon.decode(file.Read("kills.txt"))

return data[ply:SteamID()]

end

– To put this to use, we could make concommand that prints their saved kills

local function PrintKills(ply)

-- Get the kills and print it to their chat
ply:ChatPrint("You had " .. GetKills(ply) .. " kills on this server last time.")

end

– Make the concommand
concommand.Add(“PrintKills”,PrintKills)[/lua]

something like what? the code is just instantly dissappearing when the page loads.

[editline]08:15AM[/editline]

nevermind just screenied before it disappeared again. thank you very much.

It does it for people with internet explorer get firefox

unfortunately i cant. my internet explorer is bugged it wont let me install anything.

Google Chrome

That makes no sense, your browser can’t inhibit you from installing things.

well for some reason it wont let me install stuff, add favourite websites, copy and paste and the blue bar at the top that should have text is empty

It seems you have the case of a ton of virus/spyware.:eng101:
I’d advise scanning with Spybot or a similar program. If you can’t download it put it on an USB stick or something similar.