Ok so Im trying to set up a custom missions mod. Pretty what I’m trying to do here is when you press the button the panel closes and your steamid is logged into a data txt file. I tried to make it so if your steamid is in the txt file it disables the button so you can not do that mission again. Iv tried to read wiki, google, other facepunch post, other peoples data code, and youtube and couldnt find any info on how to go about this.
here is the code and this is all run on client side. [p.s. the net message just spawns an entity.]
[p.s.s. the commented out things are the stuff I tried and didnt work so I commented them out.]
local tablesdata = {}
local tablesdata = util.JSONToTable( file.Read( "mission_s/missions.txt" ) )
--if not tablesdata then return end
local data = {}
-- for _, data in ipairs( tablesdata ) do
local tablesdata = {}
local Mission1 = vgui.Create("DButton", mainmenu)
Mission1:SetSize(150, 40)
Mission1:SetPos(105, 55)
Mission1:SetText("Grab Ammo")
if tablesdata then
for k, v in pairs( tablesdata ) do
pl.Inventory:SetItem( k, itemstore.Item( v.Data ) )
end
end
--if (ply:SteamID()) == data.steamid then
--Mission1:SetEnabled( )
--end
Mission1.Paint = function(self, w, h)
draw.RoundedBox(0, 0, 0, w, h, Color(255,255,255))
end
Mission1.DoClick = function( self, ply )
local ply = LocalPlayer()
net.Start("MISSION_1")
net.SendToServer()
print("dfsdfsdfsdf")
data.steamid = ply:SteamID()
table.insert( tablesdata, data )
print()
file.Append( "mission_s/missions.txt", util.TableToJSON( tablesdata ) )
end
--end