//io file

//thank you SMS reborn for being reusable!
//Y7GDSUYFHIDJPK AAAAAAAAAAAHHHHHHHHH!!!!!!!!

//if you use this manually and mess something up, its not my fault!
COM_AddCommand("takis_load", function(p, a1,a2)
if a1 == nil
CONS_Printf(p,"\x85"+"Do not use this command manually! You may risk messing up Soap or your config!")
return
end

a1 = tonumber(a1) //Turn all of you to numbers!
a2 = tonumber(a2)

//insert to buffer or set vars directly?
//well i say set vars as to  not clutter up the player's console
local takis = p.takistable

if a1 == 1
	takis.io.nostrafe = 1
elseif a1 == 0
	takis.io.nostrafe = 0
else
	CONS_Printf(p,"\x85"+"Error loading No-Strafe! Defaulting to 0...")
end

if a1 == 1
	takis.io.nohappyhour = 1
elseif a1 == 0
	takis.io.nohappyhour = 0
else
	CONS_Printf(p,"\x85"+"Error loading No Happy Hour! Defaulting to 0...")
end

CONS_Printf(p, "\x82Loaded "..skins[TAKIS_SKIN].realname.."' Settings!")
end)

rawset(_G, "TakisSaveStuff", function(p, silent)
	//write
	local a1 = 0 
	local a2 = 0 

	--Okay, let's generate this autoconfig command. Since it'd be a pain to type out/remember, we'll auto-execute this when SMS is loaded.
	--It'll also let players make commands that load alongside SMS, such as a bind or naming themselves Super Mystic <name> or whatever.
	local t = p.takistable.io
	
	if t.nostrafe then a1 = 1 else a1 = 0 end
	if t.nohappyhour then a1 = 1 else a1 = 0 end
	
	if io
	
		local file = io.openlocal("client/takisthefox/config.dat", "w+")
		file:write("takis_load "+a1+" "+a2)
			
		if not silent
			CONS_Printf(p, "\x82Saved "..skins[TAKIS_SKIN].realname.."' settings!")
		end
			
		file:close()
		
	end
end)

rawset(_G, "TakisLoadStuff", function(p)
	
	if p.takistable.io.loaded
		return
	end
	
	if io --load savefile
		local file = io.openlocal("client/takisthefox/config.dat")
		
		
		//load file
		if file 
		
			local code = file:read("*a")
			
			if code ~= nil and not (string.find(code, ";"))
				COM_BufInsertText(p, code)
				p.takistable.io.loaded = true
			end
		
			file:close()
		
		end
		
	end
end)

