Saving guns

im making a gamemode where the players get new weapons after killing NPCs. i want it to save when the player joins other servers so that he can come back to his weapons later how might i do this?

You could try something like this.

[lua]if not file.Exists(“weapons.txt”) then file.Write(“weapons.txt”,glon.encode({})) end

hook.Add(“PlayerDisconnect”,“SaveWeapons”,function(pl)
local data = glon.decode(file.Read(“weapons.txt”))
local weapons = {}
for _,v in ipairs(pl:GetWeapons()) do
table.insert(weapons,v:GetClass())
data[pl:SteamID()] = weapons
file.Write(“weapons.txt”,data)
end)

hook.Add(“PlayerLoadout”,“LoadWeapons”,function(pl)
local data = glon.decode(file.Read(“weapons.txt”))[pl:SteamID()]
for _,v in ipairs(data) do pl:Give(v) end
end)[/lua]

Basically, when they leave you save the weapons in their possession and write it to a text file. Then when they get their weapons it loads from the text file.