diff --git a/lua/gmod_integration/client/cl_net.lua b/lua/gmod_integration/client/cl_net.lua index 0d65056..84584b4 100644 --- a/lua/gmod_integration/client/cl_net.lua +++ b/lua/gmod_integration/client/cl_net.lua @@ -14,7 +14,7 @@ function gmInte.SendNet(id, args, func) net.Start("gmIntegration") net.WriteUInt(id, 8) net.WriteString(util.TableToJSON(args || {})) - func && func() + if (func) then func() end net.SendToServer() end @@ -28,5 +28,5 @@ local netFunc = { net.Receive("gmIntegration", function() local id = net.ReadUInt(8) local args = util.JSONToTable(net.ReadString()) - netFunc[id] && netFunc[id](args) + if (netFunc[id]) then netFunc[id](args) end end) \ No newline at end of file diff --git a/lua/gmod_integration/server/sv_net.lua b/lua/gmod_integration/server/sv_net.lua index 3342ef9..c037cd5 100644 --- a/lua/gmod_integration/server/sv_net.lua +++ b/lua/gmod_integration/server/sv_net.lua @@ -16,7 +16,7 @@ function gmInte.SendNet(id, data, ply, func) net.Start("gmIntegration") net.WriteUInt(id, 8) net.WriteString(util.TableToJSON(data)) - func && func() + if (func) then func() end net.Send(ply) end @@ -31,5 +31,5 @@ net.Receive("gmIntegration", function(len, ply) if !ply:IsPlayer() then return end local id = net.ReadUInt(8) local data = util.JSONToTable(net.ReadString() || "{}") - netFuncs[id] && netFuncs[id](ply, data) + if (netFuncs[id]) then netFuncs[id](ply, data) end end) \ No newline at end of file diff --git a/lua/gmod_integration/server/sv_websocket.lua b/lua/gmod_integration/server/sv_websocket.lua index e46524a..b71b552 100644 --- a/lua/gmod_integration/server/sv_websocket.lua +++ b/lua/gmod_integration/server/sv_websocket.lua @@ -1,3 +1,9 @@ +// +// WebSocket +// + +if (!GWSockets) then return gmInte.logError("GWSockets not found!") end + require("gwsockets") local socket = GWSockets.createWebSocket("wss://ws.gmod-integration.com") diff --git a/lua/gmod_integration/shared/sh_http.lua b/lua/gmod_integration/shared/sh_http.lua index 252488d..36db90b 100644 --- a/lua/gmod_integration/shared/sh_http.lua +++ b/lua/gmod_integration/shared/sh_http.lua @@ -21,7 +21,9 @@ local function sendHTTP(params) gmInte.log("HTTP Response: " .. code, true) gmInte.log("HTTP Body: " .. body, true) if (string.sub(code, 1, 1) == "2") then - params.success && params.success(body, code, headers) + if (params.success) then + params.success(body, code, headers) + end else gmInte.logError("HTTP Request failed with code " .. code .. " and body " .. body) end diff --git a/lua/gmod_integration/shared/sh_main.lua b/lua/gmod_integration/shared/sh_main.lua index 46173c5..6f5b40e 100644 --- a/lua/gmod_integration/shared/sh_main.lua +++ b/lua/gmod_integration/shared/sh_main.lua @@ -12,5 +12,5 @@ end function gmInte.logError(msg, debug) if (debug && !gmInte.config.debug) then return end print("[" .. os.date("%Y-%m-%d %H:%M:%S") .. "] [Gmod Integration] [ERROR] " .. msg) - debug && print(debug.traceback()) + if (debug) then print(debug.traceback()) end end \ No newline at end of file