better file load

This commit is contained in:
Linventif 2023-09-26 19:10:46 +02:00
parent 61d59d886c
commit 878008e719
2 changed files with 16 additions and 5 deletions

View File

@ -4,9 +4,9 @@ if game.SinglePlayer() then return end
// Variables
//
gmInte = gmInte || {}
gmInte.version = "0.1.2"
gmInte.config = gmInte.config || {}
gmInte = {}
gmInte.version = "0.1.3"
gmInte.config = {}
//
// Functions
@ -24,10 +24,11 @@ local function loadConfig()
local oldConfig = util.JSONToTable(file.Read("gm_integration/config.json", "DATA"))
if (!oldConfig.version || (oldConfig.version < gmInte.version)) then
if (oldConfig.version < "0.1.2") then
if (oldConfig.version && (oldConfig.version < "0.1.2")) then
gmInte.config.id = oldConfig.id
gmInte.config.token = oldConfig.token
else
print(" | Merging Config | gmod_integration/sv_config.lua")
table.Merge(gmInte.config, oldConfig)
end
gmInte.config.version = gmInte.version

View File

@ -31,4 +31,14 @@ function socket:onError(txt)
gmInte.logError("WebSocket Error: " .. txt)
end
socket:open()
function gmInte.websocketSend(data)
socket:send(util.TableToJSON(data))
end
hook.Add("InitPostEntity", "gmInte:ServerReady:WebSocket", function()
if (gmInte.config.websocket) then wsConnect() end
end)
if (gmInte.config.debug) then wsConnect() end
print(gmInte.config.debug && "WebSocket Debug Mode" || "WebSocket")