mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:07:34 +00:00
fix: version + config
This commit is contained in:
parent
96fa9f1190
commit
843b1ddfcf
|
@ -45,5 +45,5 @@ function gmInte.applyPaint(element, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.getFrameName(name)
|
function gmInte.getFrameName(name)
|
||||||
return "Gmod Integration v" .. gmInte.config.version .. " - " .. name
|
return "Gmod Integration v" .. (gmInte.version || "0.0.0") .. " - " .. name
|
||||||
end
|
end
|
|
@ -355,6 +355,9 @@ end
|
||||||
function gmInte.openConfigMenu(data)
|
function gmInte.openConfigMenu(data)
|
||||||
local needRestart = false
|
local needRestart = false
|
||||||
|
|
||||||
|
if (gmInte.openAdminPanel) then return end
|
||||||
|
gmInte.openAdminPanel = true
|
||||||
|
|
||||||
local frame = vgui.Create("DFrame")
|
local frame = vgui.Create("DFrame")
|
||||||
frame:SetSize(400, (600 / 1080) * ScrH())
|
frame:SetSize(400, (600 / 1080) * ScrH())
|
||||||
frame:Center()
|
frame:Center()
|
||||||
|
@ -507,6 +510,7 @@ function gmInte.openConfigMenu(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
frame.OnClose = function()
|
frame.OnClose = function()
|
||||||
|
gmInte.openAdminPanel = false
|
||||||
if (needRestart) then gmInte.needRestart() end
|
if (needRestart) then gmInte.needRestart() end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -515,5 +519,5 @@ end
|
||||||
// Concommands
|
// Concommands
|
||||||
//
|
//
|
||||||
|
|
||||||
concommand.Add("gmod_integration_admin", gmInte.openAdminConfig)
|
concommand.Add("gmod_integration_admin", function() gmInte.SendNet("getConfig") end)
|
||||||
concommand.Add("gmi_admin", gmInte.openAdminConfig)
|
concommand.Add("gmi_admin", function() gmInte.SendNet("getConfig") end)
|
|
@ -36,6 +36,7 @@ local netReceive = {
|
||||||
end,
|
end,
|
||||||
[5] = function(data)
|
[5] = function(data)
|
||||||
gmInte.config = table.Merge(gmInte.config, data.config)
|
gmInte.config = table.Merge(gmInte.config, data.config)
|
||||||
|
gmInte.version = data.other.version
|
||||||
if (!data.other.aprovedCredentials) then RunConsoleCommand("gmod_integration_admin") end
|
if (!data.other.aprovedCredentials) then RunConsoleCommand("gmod_integration_admin") end
|
||||||
end,
|
end,
|
||||||
[6] = function(data)
|
[6] = function(data)
|
||||||
|
|
|
@ -15,10 +15,10 @@ function gmInte.saveSetting(setting, value)
|
||||||
file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true))
|
file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true))
|
||||||
gmInte.log("Setting Saved")
|
gmInte.log("Setting Saved")
|
||||||
|
|
||||||
// send to all players if it's a public setting
|
// send to all players the new public config
|
||||||
for _, ply in pairs(player.GetAll()) do
|
for _, ply in pairs(player.GetAll()) do
|
||||||
if (ply:IsValid() && ply:IsPlayer(ply)) then
|
if (ply:IsValid() && ply:IsPlayer(ply)) then
|
||||||
gmInte.log("Sending new Public Config to " .. ply:Nick())
|
gmInte.log("Sending new Public Config to " .. ply:Nick(), true)
|
||||||
gmInte.publicGetConfig(ply)
|
gmInte.publicGetConfig(ply)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -69,10 +69,10 @@ function gmInte.publicGetConfig(ply)
|
||||||
["debug"] = gmInte.config.debug,
|
["debug"] = gmInte.config.debug,
|
||||||
["apiFQDN"] = gmInte.config.apiFQDN,
|
["apiFQDN"] = gmInte.config.apiFQDN,
|
||||||
["websocketFQDN"] = gmInte.config.websocketFQDN,
|
["websocketFQDN"] = gmInte.config.websocketFQDN,
|
||||||
["version"] = gmInte.config.version,
|
|
||||||
},
|
},
|
||||||
["other"] = {
|
["other"] = {
|
||||||
["aprovedCredentials"] = gmInte.aprovedCredentials,
|
["aprovedCredentials"] = gmInte.aprovedCredentials,
|
||||||
|
["version"] = gmInte.version,
|
||||||
}
|
}
|
||||||
}, ply)
|
}, ply)
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,7 @@ function gmInte.http.requestAPI(params)
|
||||||
local method = params.method || "GET"
|
local method = params.method || "GET"
|
||||||
local success = params.success || function() end
|
local success = params.success || function() end
|
||||||
local failed = params.failed || function() end
|
local failed = params.failed || function() end
|
||||||
local version = gmInte.config.version || "Unknown"
|
local version = gmInte.version || "Unknown"
|
||||||
local showableBody = showableBody(params.endpoint)
|
local showableBody = showableBody(params.endpoint)
|
||||||
local localRequestID = util.CRC(tostring(SysTime()))
|
local localRequestID = util.CRC(tostring(SysTime()))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user