local load = io.openlocal("client/mint/mintvoice.dat", "r")
print("Loading file...")
if load != nil
local read = load:read("*n")
if read==nil
CONS_Printf(p, "not a number bru, This session will use the default setting.")
else
if read < 3 and read >= 0
print("File loaded successfully!")
S_StartSound(nil, sfx_nxdone, p)
else
print("Out of range. This session will use the default setting.")
end
end
io.close(load)
else
print("mintvoice.dat is missing. Creating a new one..")
S_StartSound(nil, sfx_adderr)
end

local configplayer

local function valid(mo)
return mo and mo.valid
end

local OBB = "client/mint/mintvoice.dat"

addHook("ThinkFrame", do
if valid(consoleplayer)
and not valid(configplayer)
configplayer = consoleplayer
local file = io.openlocal(OBB)
if file
local num = file:read("*n")
COM_BufInsertText(consoleplayer, "mintvoice "..num)
file:close()
elseif not file
COM_BufInsertText(consoleplayer, "mintvoice 2")
end
end
end)

local function MintVoice(p, arg)
local mint = p.minttable
local s = p.realmo

if s and s.valid
if arg
if arg=="off" or arg=="1"
p.mintvoice = 1
CONS_Printf(p, "\n"+"Set Mint's voice to Off.")
if io and p==consoleplayer
local file = io.openlocal(OBB, "w+")
file:write(p.mintvoice)
file:close()
end
elseif arg=="on" or arg=="2"
p.mintvoice = 2
CONS_Printf(p, "\n"+"Set Mint's voice to On.")
if io and p==consoleplayer
local file = io.openlocal(OBB, "w+")
file:write(p.mintvoice)
file:close()
end
end
else
CONS_Printf(p, "mintvoice <on/off> | Toggles Mint's voice. Default is on.")
S_StartSound(nil, sfx_ncspec, p)
end
else
CONS_Printf(p, "You can't do this right now.")
S_StartSound(nil, sfx_adderr, p)
end
end
COM_AddCommand("mintvoice", function(p, arg)
MintVoice(p, arg)
end)