mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-16 13:23:46 +03:00
Upload
This commit is contained in:
88
addons/vyhub-gmod/lua/vyhub/server/sv_config.lua
Normal file
88
addons/vyhub-gmod/lua/vyhub/server/sv_config.lua
Normal file
@@ -0,0 +1,88 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
local f = string.format
|
||||
|
||||
function VyHub.Config:load_cache_config()
|
||||
local ccfg = VyHub.Cache:get("config")
|
||||
|
||||
if ccfg != nil and #table.GetKeys(ccfg) > 0 then
|
||||
VyHub.Config = table.Merge(VyHub.Config, ccfg)
|
||||
VyHub:msg(f("Loaded cache config values: %s", table.concat(table.GetKeys(ccfg), ', ')))
|
||||
end
|
||||
end
|
||||
|
||||
concommand.Add("vh_setup", function (ply, _, args)
|
||||
if not VyHub.Util:is_server(ply) then return end
|
||||
|
||||
if not args[1] or not args[2] or not args[3] then return end
|
||||
|
||||
local ccfg = VyHub.Cache:get("config")
|
||||
|
||||
if not istable(ccfg) then
|
||||
ccfg = {}
|
||||
end
|
||||
|
||||
ccfg["api_key"] = args[1]
|
||||
ccfg["api_url"] = args[2]
|
||||
ccfg["server_id"] = args[3]
|
||||
|
||||
VyHub.Cache:save("config", ccfg)
|
||||
|
||||
for key, value in pairs(ccfg) do
|
||||
VyHub.Config[key] = value
|
||||
end
|
||||
|
||||
VyHub:msg(f("Successfully set initial config, please wait up to one minute for VyHub to initialize (%s, %s, %s)", args[1], args[2], args[3]))
|
||||
end)
|
||||
|
||||
concommand.Add("vh_config", function (ply, _, args)
|
||||
if not VyHub.Util:is_server(ply) then return end
|
||||
|
||||
local ccfg = VyHub.Cache:get("config")
|
||||
|
||||
if not args[1] or not args[2] then
|
||||
if istable(ccfg) then
|
||||
VyHub:msg("Additional config options:")
|
||||
PrintTable(ccfg)
|
||||
else
|
||||
VyHub:msg("No additional config options set.")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local key = args[1]
|
||||
local value = args[2]
|
||||
|
||||
if not istable(ccfg) then
|
||||
ccfg = {}
|
||||
end
|
||||
|
||||
if value == "false" then
|
||||
value = false
|
||||
elseif value == "true" then
|
||||
value = true
|
||||
end
|
||||
|
||||
ccfg[key] = value
|
||||
VyHub.Cache:save("config", ccfg)
|
||||
|
||||
VyHub.Config[key] = value
|
||||
|
||||
VyHub:msg(f("Successfully set config value %s.", key))
|
||||
end)
|
||||
|
||||
concommand.Add("vh_config_reset", function (ply)
|
||||
if not VyHub.Util:is_server(ply) then return end
|
||||
|
||||
VyHub.Cache:save("config", {})
|
||||
|
||||
VyHub:msg(f("Successfully cleared additional config.", key))
|
||||
end)
|
||||
Reference in New Issue
Block a user