diff --git a/lua/autorun/gmod_integration.lua b/lua/autorun/gmod_integration.lua index 6863687..48cbfb2 100644 --- a/lua/autorun/gmod_integration.lua +++ b/lua/autorun/gmod_integration.lua @@ -5,7 +5,7 @@ if game.SinglePlayer() then return end // gmInte = {} -gmInte.version = "0.2.0" +gmInte.version = "0.2.1" gmInte.config = { ["redownloadMaterials"] = false, } diff --git a/lua/gmod_integration/server/sv__websocket.lua b/lua/gmod_integration/server/sv__websocket.lua index fbebd73..606c749 100644 --- a/lua/gmod_integration/server/sv__websocket.lua +++ b/lua/gmod_integration/server/sv__websocket.lua @@ -2,12 +2,16 @@ // WebSocket // -if (!gmInte.config.websocket) then return end - -require("gwsockets") +// TODO made a proper system to detect if the server need to be connected to the websocket +if (!gmInte.config.syncChat && !gmInte.config.websocket) then + gmInte.log("WebSocket is disabled", true) + return +end if (!GWSockets) then return gmInte.logError("GWSockets is not installed! Please install it from https://github.com/FredyH/GWSockets") end +require("gwsockets") + local socket = GWSockets.createWebSocket("wss://ws.gmod-integration.com") // Authentication @@ -47,7 +51,7 @@ function gmInte.websocketWrite(data) socket:write(util.TableToJSON(data || {})) end -timer.Create("gmInte:WebSocket:CheckConnection", 60, 0, function() +timer.Create("gmInte:WebSocket:CheckConnection", 4, 0, function() if (!socket:isConnected()) then socket:open() end diff --git a/lua/gmod_integration/server/sv_main.lua b/lua/gmod_integration/server/sv_main.lua index 83119c1..f6443e0 100644 --- a/lua/gmod_integration/server/sv_main.lua +++ b/lua/gmod_integration/server/sv_main.lua @@ -67,13 +67,11 @@ end function gmInte.playerSay(ply, text, team) if (!gmInte.config.syncChat) then return end - local triggerInfo = getTriggerInfo(text) - if (!triggerInfo && !gmInte.config.chatTriggerAll) then return end gmInte.post("/server/user/say", { ["steamID64"] = ply:SteamID64(), - ["message"] = string.sub(text, string.len(triggerInfo.trigger) + 1), + ["message"] = text, ["name"] = ply:Nick(), ["usergroup"] = ply:GetUserGroup(), ["message_info"] = triggerInfo diff --git a/lua/gmod_integration/sv_config.lua b/lua/gmod_integration/sv_config.lua index 3bb98ed..c6d464c 100644 --- a/lua/gmod_integration/sv_config.lua +++ b/lua/gmod_integration/sv_config.lua @@ -34,33 +34,6 @@ gmInte.config.token = "" // Server Token */ gmInte.config.websocket = false // If true, the addon will use the websocket instead of the http requests -// Chat -gmInte.config.chatTriggerAll = false // If true, the addon will sync all the messages in the chat -gmInte.config.chatTrigger = { -/* Example: - ["/example "] = { - ["prefix"] = "[Example] ", // The prefix of the message - ["show_rank"] = false, // If true, the addon will show the rank of the player in the prefix - ["anonymous"] = false, // If true, the addon will not show the name and the avatar of the player in the message - ["channel"] = "admin_sync_chat" // If set, the addon will use a custom channel to sync the message (use in multi chat syncronization) - }, - ["/admin_chat "] = { - ["prefix"] = "[Admin Chat]", - ["show_rank"] = true, - ["channel"] = "discord_channel_id_admin_chat" - }, -*/ - ["// "] = { - ["prefix"] = "", - ["show_rank"] = false, - ["anonymous"] = false, - ["custom_id"] = "admin_sync_chat" - }, - ["/ano "] = { - ["anonymous"] = true, - }, -} // Trigger to sync the messages in a discord channel (the key is the trigger and the value is the replacement) - // Other gmInte.config.forcePlayerLink = false // If true, the addon will force the players to link their discord account to their steam account before playing gmInte.config.supportLink = "" // The link of your support (shown when a player do not have the requiments to join the server)