From a605d9fbe7f45febf2d7683b009f6df746c0febd Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 17 Apr 2025 03:22:36 +0000 Subject: [PATCH 01/35] =?UTF-8?q?refact:=20do=20a=20full=20re=C3=A8archite?= =?UTF-8?q?cture=20of=20the=20lua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/autorun/gmod_integration.lua | 2 +- lua/gmod_integration/{shared => core/api}/sh_api_format.lua | 0 lua/gmod_integration/{shared => core/api}/sh_http.lua | 0 lua/gmod_integration/{server => core/api}/sv__websocket.lua | 0 .../{client => core/config}/cl_gui_admin.lua | 0 lua/gmod_integration/{client => core/config}/cl_hook.lua | 6 ------ lua/gmod_integration/{server => core/config}/sv_con.lua | 0 lua/gmod_integration/{ => core/config}/sv_config.lua | 0 .../{server => core/config}/sv_settings.lua | 0 lua/gmod_integration/{client => core/net}/cl_net.lua | 0 lua/gmod_integration/{server => core/net}/sv_net.lua | 0 .../{server => core/security}/sv_tokens.lua | 0 lua/gmod_integration/{client => core/ui}/cl__color.lua | 0 .../{client => core/ui}/cl_context_menu.lua | 0 lua/gmod_integration/{client => core/ui}/cl_font.lua | 0 lua/gmod_integration/{client => core/ui}/cl_materials.lua | 0 lua/gmod_integration/{client => core/utils}/cl_main.lua | 0 lua/gmod_integration/{shared => core/utils}/sh_con.lua | 0 .../{shared => core/utils}/sh_player_meta.lua | 0 .../{shared/sh_main.lua => core/utils/sh_utils.lua} | 0 lua/gmod_integration/{shared => languages}/sh__language.lua | 6 +++--- lua/gmod_integration/{shared => }/languages/sh_de.lua | 0 lua/gmod_integration/{shared => }/languages/sh_en.lua | 0 lua/gmod_integration/{shared => }/languages/sh_es.lua | 0 lua/gmod_integration/{shared => }/languages/sh_fr.lua | 0 lua/gmod_integration/{shared => }/languages/sh_it.lua | 0 lua/gmod_integration/{shared => }/languages/sh_nl.lua | 0 lua/gmod_integration/{shared => }/languages/sh_pl.lua | 0 lua/gmod_integration/{shared => }/languages/sh_ru.lua | 0 lua/gmod_integration/{shared => }/languages/sh_tr.lua | 0 .../{server => modules/console_commands}/sv_rcon.lua | 0 .../money_trackers}/chatm/sv_atm.lua | 0 .../money_trackers}/darkrp/sv_darkrp.lua | 0 .../{server => modules/player_whitelist}/sv_filtrers.lua | 0 .../players_filter_branch}/cl_gui_wrong_branch.lua | 0 .../modules/players_filter_branch/cl_hook copy.lua | 5 +++++ .../players_filter_link_account}/cl_gui_link.lua | 0 .../players_filter_link_account}/sv_players_verif.lua | 0 .../{server => modules/players_logs}/sv_players.lua | 0 .../{client => modules/report_bugs}/cl_report_bug.lua | 0 .../{shared => modules/report_errors}/sh_errors.lua | 0 .../{client => modules/screenshots}/cl_screenshots.lua | 0 .../{server => modules/server_status}/sv_status.lua | 0 .../{server => modules/sync_bans}/sv_sync_bans.lua | 0 .../{client => modules/sync_chat}/cl_sync_chat.lua | 0 .../{server => modules/sync_chat}/sv_sync_chat.lua | 0 .../{server => modules/sync_kicks}/sv_sync_kicks.lua | 0 .../{server => modules/sync_pseudos}/sv_sync_names.lua | 0 .../{server => modules/sync_usergroups}/sv_sync_roles.lua | 0 .../{server => modules/sync_warns/awarn3}/sv_sync_warn.lua | 0 50 files changed, 9 insertions(+), 10 deletions(-) rename lua/gmod_integration/{shared => core/api}/sh_api_format.lua (100%) rename lua/gmod_integration/{shared => core/api}/sh_http.lua (100%) rename lua/gmod_integration/{server => core/api}/sv__websocket.lua (100%) rename lua/gmod_integration/{client => core/config}/cl_gui_admin.lua (100%) rename lua/gmod_integration/{client => core/config}/cl_hook.lua (65%) rename lua/gmod_integration/{server => core/config}/sv_con.lua (100%) rename lua/gmod_integration/{ => core/config}/sv_config.lua (100%) rename lua/gmod_integration/{server => core/config}/sv_settings.lua (100%) rename lua/gmod_integration/{client => core/net}/cl_net.lua (100%) rename lua/gmod_integration/{server => core/net}/sv_net.lua (100%) rename lua/gmod_integration/{server => core/security}/sv_tokens.lua (100%) rename lua/gmod_integration/{client => core/ui}/cl__color.lua (100%) rename lua/gmod_integration/{client => core/ui}/cl_context_menu.lua (100%) rename lua/gmod_integration/{client => core/ui}/cl_font.lua (100%) rename lua/gmod_integration/{client => core/ui}/cl_materials.lua (100%) rename lua/gmod_integration/{client => core/utils}/cl_main.lua (100%) rename lua/gmod_integration/{shared => core/utils}/sh_con.lua (100%) rename lua/gmod_integration/{shared => core/utils}/sh_player_meta.lua (100%) rename lua/gmod_integration/{shared/sh_main.lua => core/utils/sh_utils.lua} (100%) rename lua/gmod_integration/{shared => languages}/sh__language.lua (71%) rename lua/gmod_integration/{shared => }/languages/sh_de.lua (100%) rename lua/gmod_integration/{shared => }/languages/sh_en.lua (100%) rename lua/gmod_integration/{shared => }/languages/sh_es.lua (100%) rename lua/gmod_integration/{shared => }/languages/sh_fr.lua (100%) rename lua/gmod_integration/{shared => }/languages/sh_it.lua (100%) rename lua/gmod_integration/{shared => }/languages/sh_nl.lua (100%) rename lua/gmod_integration/{shared => }/languages/sh_pl.lua (100%) rename lua/gmod_integration/{shared => }/languages/sh_ru.lua (100%) rename lua/gmod_integration/{shared => }/languages/sh_tr.lua (100%) rename lua/gmod_integration/{server => modules/console_commands}/sv_rcon.lua (100%) rename lua/gmod_integration/{server/compatibility => modules/money_trackers}/chatm/sv_atm.lua (100%) rename lua/gmod_integration/{server/compatibility => modules/money_trackers}/darkrp/sv_darkrp.lua (100%) rename lua/gmod_integration/{server => modules/player_whitelist}/sv_filtrers.lua (100%) rename lua/gmod_integration/{client => modules/players_filter_branch}/cl_gui_wrong_branch.lua (100%) create mode 100644 lua/gmod_integration/modules/players_filter_branch/cl_hook copy.lua rename lua/gmod_integration/{client => modules/players_filter_link_account}/cl_gui_link.lua (100%) rename lua/gmod_integration/{server => modules/players_filter_link_account}/sv_players_verif.lua (100%) rename lua/gmod_integration/{server => modules/players_logs}/sv_players.lua (100%) rename lua/gmod_integration/{client => modules/report_bugs}/cl_report_bug.lua (100%) rename lua/gmod_integration/{shared => modules/report_errors}/sh_errors.lua (100%) rename lua/gmod_integration/{client => modules/screenshots}/cl_screenshots.lua (100%) rename lua/gmod_integration/{server => modules/server_status}/sv_status.lua (100%) rename lua/gmod_integration/{server => modules/sync_bans}/sv_sync_bans.lua (100%) rename lua/gmod_integration/{client => modules/sync_chat}/cl_sync_chat.lua (100%) rename lua/gmod_integration/{server => modules/sync_chat}/sv_sync_chat.lua (100%) rename lua/gmod_integration/{server => modules/sync_kicks}/sv_sync_kicks.lua (100%) rename lua/gmod_integration/{server => modules/sync_pseudos}/sv_sync_names.lua (100%) rename lua/gmod_integration/{server => modules/sync_usergroups}/sv_sync_roles.lua (100%) rename lua/gmod_integration/{server => modules/sync_warns/awarn3}/sv_sync_warn.lua (100%) diff --git a/lua/autorun/gmod_integration.lua b/lua/autorun/gmod_integration.lua index fc22af1..f004d73 100644 --- a/lua/autorun/gmod_integration.lua +++ b/lua/autorun/gmod_integration.lua @@ -1,6 +1,6 @@ if game.SinglePlayer() then return print("Gmod Integration is not supported in Singleplayer!") end gmInte = gmInte || {} -gmInte.version = "0.4.9" +gmInte.version = "0.5.0" gmInte.config = {} gmInte.materials = {} local function loadServerConfig() diff --git a/lua/gmod_integration/shared/sh_api_format.lua b/lua/gmod_integration/core/api/sh_api_format.lua similarity index 100% rename from lua/gmod_integration/shared/sh_api_format.lua rename to lua/gmod_integration/core/api/sh_api_format.lua diff --git a/lua/gmod_integration/shared/sh_http.lua b/lua/gmod_integration/core/api/sh_http.lua similarity index 100% rename from lua/gmod_integration/shared/sh_http.lua rename to lua/gmod_integration/core/api/sh_http.lua diff --git a/lua/gmod_integration/server/sv__websocket.lua b/lua/gmod_integration/core/api/sv__websocket.lua similarity index 100% rename from lua/gmod_integration/server/sv__websocket.lua rename to lua/gmod_integration/core/api/sv__websocket.lua diff --git a/lua/gmod_integration/client/cl_gui_admin.lua b/lua/gmod_integration/core/config/cl_gui_admin.lua similarity index 100% rename from lua/gmod_integration/client/cl_gui_admin.lua rename to lua/gmod_integration/core/config/cl_gui_admin.lua diff --git a/lua/gmod_integration/client/cl_hook.lua b/lua/gmod_integration/core/config/cl_hook.lua similarity index 65% rename from lua/gmod_integration/client/cl_hook.lua rename to lua/gmod_integration/core/config/cl_hook.lua index 6663821..f6db1f8 100644 --- a/lua/gmod_integration/client/cl_hook.lua +++ b/lua/gmod_integration/core/config/cl_hook.lua @@ -1,9 +1,3 @@ -hook.Add("InitPostEntity", "gmInte:Ply:Ready", function() - gmInte.SendNet("ready", { - ["branch"] = LocalPlayer():gmInteGetBranch() - }) -end) - hook.Add("OnPlayerChat", "gmInte:OnPlayerChat:AdminCmd", function(ply, strText, bTeamOnly, bPlayerIsDead) if ply != LocalPlayer() then return end strText = string.lower(strText) diff --git a/lua/gmod_integration/server/sv_con.lua b/lua/gmod_integration/core/config/sv_con.lua similarity index 100% rename from lua/gmod_integration/server/sv_con.lua rename to lua/gmod_integration/core/config/sv_con.lua diff --git a/lua/gmod_integration/sv_config.lua b/lua/gmod_integration/core/config/sv_config.lua similarity index 100% rename from lua/gmod_integration/sv_config.lua rename to lua/gmod_integration/core/config/sv_config.lua diff --git a/lua/gmod_integration/server/sv_settings.lua b/lua/gmod_integration/core/config/sv_settings.lua similarity index 100% rename from lua/gmod_integration/server/sv_settings.lua rename to lua/gmod_integration/core/config/sv_settings.lua diff --git a/lua/gmod_integration/client/cl_net.lua b/lua/gmod_integration/core/net/cl_net.lua similarity index 100% rename from lua/gmod_integration/client/cl_net.lua rename to lua/gmod_integration/core/net/cl_net.lua diff --git a/lua/gmod_integration/server/sv_net.lua b/lua/gmod_integration/core/net/sv_net.lua similarity index 100% rename from lua/gmod_integration/server/sv_net.lua rename to lua/gmod_integration/core/net/sv_net.lua diff --git a/lua/gmod_integration/server/sv_tokens.lua b/lua/gmod_integration/core/security/sv_tokens.lua similarity index 100% rename from lua/gmod_integration/server/sv_tokens.lua rename to lua/gmod_integration/core/security/sv_tokens.lua diff --git a/lua/gmod_integration/client/cl__color.lua b/lua/gmod_integration/core/ui/cl__color.lua similarity index 100% rename from lua/gmod_integration/client/cl__color.lua rename to lua/gmod_integration/core/ui/cl__color.lua diff --git a/lua/gmod_integration/client/cl_context_menu.lua b/lua/gmod_integration/core/ui/cl_context_menu.lua similarity index 100% rename from lua/gmod_integration/client/cl_context_menu.lua rename to lua/gmod_integration/core/ui/cl_context_menu.lua diff --git a/lua/gmod_integration/client/cl_font.lua b/lua/gmod_integration/core/ui/cl_font.lua similarity index 100% rename from lua/gmod_integration/client/cl_font.lua rename to lua/gmod_integration/core/ui/cl_font.lua diff --git a/lua/gmod_integration/client/cl_materials.lua b/lua/gmod_integration/core/ui/cl_materials.lua similarity index 100% rename from lua/gmod_integration/client/cl_materials.lua rename to lua/gmod_integration/core/ui/cl_materials.lua diff --git a/lua/gmod_integration/client/cl_main.lua b/lua/gmod_integration/core/utils/cl_main.lua similarity index 100% rename from lua/gmod_integration/client/cl_main.lua rename to lua/gmod_integration/core/utils/cl_main.lua diff --git a/lua/gmod_integration/shared/sh_con.lua b/lua/gmod_integration/core/utils/sh_con.lua similarity index 100% rename from lua/gmod_integration/shared/sh_con.lua rename to lua/gmod_integration/core/utils/sh_con.lua diff --git a/lua/gmod_integration/shared/sh_player_meta.lua b/lua/gmod_integration/core/utils/sh_player_meta.lua similarity index 100% rename from lua/gmod_integration/shared/sh_player_meta.lua rename to lua/gmod_integration/core/utils/sh_player_meta.lua diff --git a/lua/gmod_integration/shared/sh_main.lua b/lua/gmod_integration/core/utils/sh_utils.lua similarity index 100% rename from lua/gmod_integration/shared/sh_main.lua rename to lua/gmod_integration/core/utils/sh_utils.lua diff --git a/lua/gmod_integration/shared/sh__language.lua b/lua/gmod_integration/languages/sh__language.lua similarity index 71% rename from lua/gmod_integration/shared/sh__language.lua rename to lua/gmod_integration/languages/sh__language.lua index d88acbe..7e42eb1 100644 --- a/lua/gmod_integration/shared/sh__language.lua +++ b/lua/gmod_integration/languages/sh__language.lua @@ -1,4 +1,4 @@ -local default = include("gmod_integration/shared/languages/sh_en.lua") +local default = include("gmod_integration/languages/sh_en.lua") local translationTable = default function gmInte.getTranslation(key, defaultTranslation, ...) local translation = translationTable[key] @@ -16,8 +16,8 @@ function gmInte.loadTranslations() if lang == "en" then translationTable = default else - if file.Exists("gmod_integration/shared/languages/sh_" .. lang .. ".lua", "LUA") then - translationTable = include("gmod_integration/shared/languages/sh_" .. lang .. ".lua") + if file.Exists("gmod_integration/languages/sh_" .. lang .. ".lua", "LUA") then + translationTable = include("gmod_integration/languages/sh_" .. lang .. ".lua") else print("Unknown Language") return diff --git a/lua/gmod_integration/shared/languages/sh_de.lua b/lua/gmod_integration/languages/sh_de.lua similarity index 100% rename from lua/gmod_integration/shared/languages/sh_de.lua rename to lua/gmod_integration/languages/sh_de.lua diff --git a/lua/gmod_integration/shared/languages/sh_en.lua b/lua/gmod_integration/languages/sh_en.lua similarity index 100% rename from lua/gmod_integration/shared/languages/sh_en.lua rename to lua/gmod_integration/languages/sh_en.lua diff --git a/lua/gmod_integration/shared/languages/sh_es.lua b/lua/gmod_integration/languages/sh_es.lua similarity index 100% rename from lua/gmod_integration/shared/languages/sh_es.lua rename to lua/gmod_integration/languages/sh_es.lua diff --git a/lua/gmod_integration/shared/languages/sh_fr.lua b/lua/gmod_integration/languages/sh_fr.lua similarity index 100% rename from lua/gmod_integration/shared/languages/sh_fr.lua rename to lua/gmod_integration/languages/sh_fr.lua diff --git a/lua/gmod_integration/shared/languages/sh_it.lua b/lua/gmod_integration/languages/sh_it.lua similarity index 100% rename from lua/gmod_integration/shared/languages/sh_it.lua rename to lua/gmod_integration/languages/sh_it.lua diff --git a/lua/gmod_integration/shared/languages/sh_nl.lua b/lua/gmod_integration/languages/sh_nl.lua similarity index 100% rename from lua/gmod_integration/shared/languages/sh_nl.lua rename to lua/gmod_integration/languages/sh_nl.lua diff --git a/lua/gmod_integration/shared/languages/sh_pl.lua b/lua/gmod_integration/languages/sh_pl.lua similarity index 100% rename from lua/gmod_integration/shared/languages/sh_pl.lua rename to lua/gmod_integration/languages/sh_pl.lua diff --git a/lua/gmod_integration/shared/languages/sh_ru.lua b/lua/gmod_integration/languages/sh_ru.lua similarity index 100% rename from lua/gmod_integration/shared/languages/sh_ru.lua rename to lua/gmod_integration/languages/sh_ru.lua diff --git a/lua/gmod_integration/shared/languages/sh_tr.lua b/lua/gmod_integration/languages/sh_tr.lua similarity index 100% rename from lua/gmod_integration/shared/languages/sh_tr.lua rename to lua/gmod_integration/languages/sh_tr.lua diff --git a/lua/gmod_integration/server/sv_rcon.lua b/lua/gmod_integration/modules/console_commands/sv_rcon.lua similarity index 100% rename from lua/gmod_integration/server/sv_rcon.lua rename to lua/gmod_integration/modules/console_commands/sv_rcon.lua diff --git a/lua/gmod_integration/server/compatibility/chatm/sv_atm.lua b/lua/gmod_integration/modules/money_trackers/chatm/sv_atm.lua similarity index 100% rename from lua/gmod_integration/server/compatibility/chatm/sv_atm.lua rename to lua/gmod_integration/modules/money_trackers/chatm/sv_atm.lua diff --git a/lua/gmod_integration/server/compatibility/darkrp/sv_darkrp.lua b/lua/gmod_integration/modules/money_trackers/darkrp/sv_darkrp.lua similarity index 100% rename from lua/gmod_integration/server/compatibility/darkrp/sv_darkrp.lua rename to lua/gmod_integration/modules/money_trackers/darkrp/sv_darkrp.lua diff --git a/lua/gmod_integration/server/sv_filtrers.lua b/lua/gmod_integration/modules/player_whitelist/sv_filtrers.lua similarity index 100% rename from lua/gmod_integration/server/sv_filtrers.lua rename to lua/gmod_integration/modules/player_whitelist/sv_filtrers.lua diff --git a/lua/gmod_integration/client/cl_gui_wrong_branch.lua b/lua/gmod_integration/modules/players_filter_branch/cl_gui_wrong_branch.lua similarity index 100% rename from lua/gmod_integration/client/cl_gui_wrong_branch.lua rename to lua/gmod_integration/modules/players_filter_branch/cl_gui_wrong_branch.lua diff --git a/lua/gmod_integration/modules/players_filter_branch/cl_hook copy.lua b/lua/gmod_integration/modules/players_filter_branch/cl_hook copy.lua new file mode 100644 index 0000000..d68d81f --- /dev/null +++ b/lua/gmod_integration/modules/players_filter_branch/cl_hook copy.lua @@ -0,0 +1,5 @@ +hook.Add("InitPostEntity", "gmInte:Ply:Ready", function() + gmInte.SendNet("ready", { + ["branch"] = LocalPlayer():gmInteGetBranch() + }) +end) \ No newline at end of file diff --git a/lua/gmod_integration/client/cl_gui_link.lua b/lua/gmod_integration/modules/players_filter_link_account/cl_gui_link.lua similarity index 100% rename from lua/gmod_integration/client/cl_gui_link.lua rename to lua/gmod_integration/modules/players_filter_link_account/cl_gui_link.lua diff --git a/lua/gmod_integration/server/sv_players_verif.lua b/lua/gmod_integration/modules/players_filter_link_account/sv_players_verif.lua similarity index 100% rename from lua/gmod_integration/server/sv_players_verif.lua rename to lua/gmod_integration/modules/players_filter_link_account/sv_players_verif.lua diff --git a/lua/gmod_integration/server/sv_players.lua b/lua/gmod_integration/modules/players_logs/sv_players.lua similarity index 100% rename from lua/gmod_integration/server/sv_players.lua rename to lua/gmod_integration/modules/players_logs/sv_players.lua diff --git a/lua/gmod_integration/client/cl_report_bug.lua b/lua/gmod_integration/modules/report_bugs/cl_report_bug.lua similarity index 100% rename from lua/gmod_integration/client/cl_report_bug.lua rename to lua/gmod_integration/modules/report_bugs/cl_report_bug.lua diff --git a/lua/gmod_integration/shared/sh_errors.lua b/lua/gmod_integration/modules/report_errors/sh_errors.lua similarity index 100% rename from lua/gmod_integration/shared/sh_errors.lua rename to lua/gmod_integration/modules/report_errors/sh_errors.lua diff --git a/lua/gmod_integration/client/cl_screenshots.lua b/lua/gmod_integration/modules/screenshots/cl_screenshots.lua similarity index 100% rename from lua/gmod_integration/client/cl_screenshots.lua rename to lua/gmod_integration/modules/screenshots/cl_screenshots.lua diff --git a/lua/gmod_integration/server/sv_status.lua b/lua/gmod_integration/modules/server_status/sv_status.lua similarity index 100% rename from lua/gmod_integration/server/sv_status.lua rename to lua/gmod_integration/modules/server_status/sv_status.lua diff --git a/lua/gmod_integration/server/sv_sync_bans.lua b/lua/gmod_integration/modules/sync_bans/sv_sync_bans.lua similarity index 100% rename from lua/gmod_integration/server/sv_sync_bans.lua rename to lua/gmod_integration/modules/sync_bans/sv_sync_bans.lua diff --git a/lua/gmod_integration/client/cl_sync_chat.lua b/lua/gmod_integration/modules/sync_chat/cl_sync_chat.lua similarity index 100% rename from lua/gmod_integration/client/cl_sync_chat.lua rename to lua/gmod_integration/modules/sync_chat/cl_sync_chat.lua diff --git a/lua/gmod_integration/server/sv_sync_chat.lua b/lua/gmod_integration/modules/sync_chat/sv_sync_chat.lua similarity index 100% rename from lua/gmod_integration/server/sv_sync_chat.lua rename to lua/gmod_integration/modules/sync_chat/sv_sync_chat.lua diff --git a/lua/gmod_integration/server/sv_sync_kicks.lua b/lua/gmod_integration/modules/sync_kicks/sv_sync_kicks.lua similarity index 100% rename from lua/gmod_integration/server/sv_sync_kicks.lua rename to lua/gmod_integration/modules/sync_kicks/sv_sync_kicks.lua diff --git a/lua/gmod_integration/server/sv_sync_names.lua b/lua/gmod_integration/modules/sync_pseudos/sv_sync_names.lua similarity index 100% rename from lua/gmod_integration/server/sv_sync_names.lua rename to lua/gmod_integration/modules/sync_pseudos/sv_sync_names.lua diff --git a/lua/gmod_integration/server/sv_sync_roles.lua b/lua/gmod_integration/modules/sync_usergroups/sv_sync_roles.lua similarity index 100% rename from lua/gmod_integration/server/sv_sync_roles.lua rename to lua/gmod_integration/modules/sync_usergroups/sv_sync_roles.lua diff --git a/lua/gmod_integration/server/sv_sync_warn.lua b/lua/gmod_integration/modules/sync_warns/awarn3/sv_sync_warn.lua similarity index 100% rename from lua/gmod_integration/server/sv_sync_warn.lua rename to lua/gmod_integration/modules/sync_warns/awarn3/sv_sync_warn.lua From ac54b3db55183f5afb26d28c645f91952747ea68 Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 17 Apr 2025 04:16:00 +0000 Subject: [PATCH 02/35] feat: add server configuration file with detailed setup instructions --- lua/gmod_integration/{core/config => }/sv_config.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lua/gmod_integration/{core/config => }/sv_config.lua (100%) diff --git a/lua/gmod_integration/core/config/sv_config.lua b/lua/gmod_integration/sv_config.lua similarity index 100% rename from lua/gmod_integration/core/config/sv_config.lua rename to lua/gmod_integration/sv_config.lua From d0880366e4c12c9ae02e8b821ddfe19d4a77ae34 Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 17 Apr 2025 04:16:13 +0000 Subject: [PATCH 03/35] refact: move a hook --- .../modules/players_filter_branch/cl_gui_wrong_branch.lua | 8 +++++++- .../modules/players_filter_branch/cl_hook copy.lua | 5 ----- 2 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 lua/gmod_integration/modules/players_filter_branch/cl_hook copy.lua diff --git a/lua/gmod_integration/modules/players_filter_branch/cl_gui_wrong_branch.lua b/lua/gmod_integration/modules/players_filter_branch/cl_gui_wrong_branch.lua index 221252e..831be44 100644 --- a/lua/gmod_integration/modules/players_filter_branch/cl_gui_wrong_branch.lua +++ b/lua/gmod_integration/modules/players_filter_branch/cl_gui_wrong_branch.lua @@ -26,4 +26,10 @@ function gmInte.openWrongBranchPopup() linkButton:SetSize(buttonGrid:GetColWide() - 10, buttonGrid:GetRowHeight()) buttonGrid:AddItem(linkButton) gmInte.applyPaint(linkButton) -end \ No newline at end of file +end + +hook.Add("InitPostEntity", "gmInte:Ply:Ready", function() + gmInte.SendNet("ready", { + ["branch"] = LocalPlayer():gmInteGetBranch() + }) +end) \ No newline at end of file diff --git a/lua/gmod_integration/modules/players_filter_branch/cl_hook copy.lua b/lua/gmod_integration/modules/players_filter_branch/cl_hook copy.lua deleted file mode 100644 index d68d81f..0000000 --- a/lua/gmod_integration/modules/players_filter_branch/cl_hook copy.lua +++ /dev/null @@ -1,5 +0,0 @@ -hook.Add("InitPostEntity", "gmInte:Ply:Ready", function() - gmInte.SendNet("ready", { - ["branch"] = LocalPlayer():gmInteGetBranch() - }) -end) \ No newline at end of file From 0eb8109ac25f2da886b5f8d6f836651d093c0233 Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 17 Apr 2025 17:32:44 +0000 Subject: [PATCH 04/35] refact: manual priority of folder / file --- lua/autorun/gmod_integration.lua | 57 ++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/lua/autorun/gmod_integration.lua b/lua/autorun/gmod_integration.lua index f004d73..b10e9b0 100644 --- a/lua/autorun/gmod_integration.lua +++ b/lua/autorun/gmod_integration.lua @@ -3,7 +3,7 @@ gmInte = gmInte || {} gmInte.version = "0.5.0" gmInte.config = {} gmInte.materials = {} -local function loadServerConfig() +local function loadConfig() RunConsoleCommand("sv_hibernate_think", "1") if !file.Exists("gm_integration", "DATA") || !file.Exists("gm_integration/config.json", "DATA") then file.CreateDir("gm_integration") @@ -12,7 +12,6 @@ local function loadServerConfig() if gmInte.config.id && gmInte.config.id != "" then return end local oldConfig = util.JSONToTable(file.Read("gm_integration/config.json", "DATA")) if !oldConfig.version || (oldConfig.version < gmInte.version) then - print(" | Merging Config | gmod_integration/sv_config.lua") table.Merge(gmInte.config, oldConfig) gmInte.config.version = gmInte.version file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true)) @@ -22,32 +21,36 @@ local function loadServerConfig() end end -local function loadAllFiles(folder) - local files, folders = file.Find(folder .. "/*", "LUA") - for k, fileName in SortedPairs(files) do - local path = folder .. "/" .. fileName - print(" | Loading File | " .. path) - if string.StartWith(fileName, "cl_") then - if SERVER then - AddCSLuaFile(path) - else - include(path) - end - elseif string.StartWith(fileName, "sv_") then - if SERVER then include(path) end - elseif string.StartWith(fileName, "sh_") then - if SERVER then AddCSLuaFile(path) end +local loadedFiles = {} +local function loadFile(folder, fileName) + local path = folder .. "/" .. fileName + if loadedFiles[path] then return end + loadedFiles[path] = true + print(" | Loading File | " .. path) + if string.StartWith(fileName, "cl_") then + if SERVER then + AddCSLuaFile(path) + else include(path) end - - if fileName == "sv_config.lua" then - loadServerConfig() - continue - end + elseif string.StartWith(fileName, "sv_") then + if SERVER then include(path) end + elseif string.StartWith(fileName, "sh_") then + if SERVER then AddCSLuaFile(path) end + include(path) end - for k, v in SortedPairs(folders, true) do - loadAllFiles(folder .. "/" .. v, name) + if fileName == "sv_config.lua" then loadConfig() end +end + +local function loadFolder(folder) + local files, folders = file.Find(folder .. "/*", "LUA") + for k, fileName in SortedPairs(files) do + loadFile(folder, fileName) + end + + for k, subFolder in SortedPairs(folders) do + loadFolder(folder .. "/" .. subFolder) end end @@ -65,5 +68,9 @@ print(" - https://gmod-integration.com/discord - ") print(" - - ") print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") print(" ") -loadAllFiles("gmod_integration") +loadFile("gmod_integration", "sv_config.lua") +loadFolder("gmod_integration/languages") +loadFolder("gmod_integration/core") +loadFolder("gmod_integration/modules") +loadFolder("gmod_integration") print(" ") \ No newline at end of file From 083aadefe376af7f7f5b5b4ee431e0278764d4eb Mon Sep 17 00:00:00 2001 From: Linventif Date: Wed, 23 Apr 2025 18:55:44 +0000 Subject: [PATCH 05/35] refact: move filters to filters whitelist --- .../sv_filtrers.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lua/gmod_integration/modules/{player_whitelist => players_filter_whitelist}/sv_filtrers.lua (100%) diff --git a/lua/gmod_integration/modules/player_whitelist/sv_filtrers.lua b/lua/gmod_integration/modules/players_filter_whitelist/sv_filtrers.lua similarity index 100% rename from lua/gmod_integration/modules/player_whitelist/sv_filtrers.lua rename to lua/gmod_integration/modules/players_filter_whitelist/sv_filtrers.lua From baadebd5176febd7463d02f145063f38d5460c9a Mon Sep 17 00:00:00 2001 From: Linventif Date: Wed, 23 Apr 2025 18:59:22 +0000 Subject: [PATCH 06/35] refact: admin menu --- .../config/{cl_gui_admin.lua => cl_admin_menu.lua} | 10 +++++++++- lua/gmod_integration/core/config/cl_hook.lua | 8 -------- 2 files changed, 9 insertions(+), 9 deletions(-) rename lua/gmod_integration/core/config/{cl_gui_admin.lua => cl_admin_menu.lua} (98%) delete mode 100644 lua/gmod_integration/core/config/cl_hook.lua diff --git a/lua/gmod_integration/core/config/cl_gui_admin.lua b/lua/gmod_integration/core/config/cl_admin_menu.lua similarity index 98% rename from lua/gmod_integration/core/config/cl_gui_admin.lua rename to lua/gmod_integration/core/config/cl_admin_menu.lua index 406d98f..d538f17 100644 --- a/lua/gmod_integration/core/config/cl_gui_admin.lua +++ b/lua/gmod_integration/core/config/cl_admin_menu.lua @@ -396,4 +396,12 @@ function gmInte.openConfigMenu(data) end concommand.Add("gmod_integration_admin", function() gmInte.SendNet("getConfig") end) -concommand.Add("gmi_admin", function() gmInte.SendNet("getConfig") end) \ No newline at end of file +concommand.Add("gmi_admin", function() gmInte.SendNet("getConfig") end) +hook.Add("OnPlayerChat", "gmInte:OnPlayerChat:AdminCmd", function(ply, strText, bTeamOnly, bPlayerIsDead) + if ply != LocalPlayer() then return end + strText = string.lower(strText) + if strText == "/gmi" || strText == "!gmi" then + gmInte.openAdminConfig() + return true + end +end) \ No newline at end of file diff --git a/lua/gmod_integration/core/config/cl_hook.lua b/lua/gmod_integration/core/config/cl_hook.lua deleted file mode 100644 index f6db1f8..0000000 --- a/lua/gmod_integration/core/config/cl_hook.lua +++ /dev/null @@ -1,8 +0,0 @@ -hook.Add("OnPlayerChat", "gmInte:OnPlayerChat:AdminCmd", function(ply, strText, bTeamOnly, bPlayerIsDead) - if ply != LocalPlayer() then return end - strText = string.lower(strText) - if strText == "/gmi" || strText == "!gmi" then - gmInte.openAdminConfig() - return true - end -end) \ No newline at end of file From 0a391e022da72b3447e3d65a188031b0dd1aa1fa Mon Sep 17 00:00:00 2001 From: Linventif Date: Wed, 23 Apr 2025 19:19:12 +0000 Subject: [PATCH 07/35] refact: change the order of core load --- lua/autorun/gmod_integration.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/autorun/gmod_integration.lua b/lua/autorun/gmod_integration.lua index b10e9b0..e139758 100644 --- a/lua/autorun/gmod_integration.lua +++ b/lua/autorun/gmod_integration.lua @@ -70,6 +70,8 @@ print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") print(" ") loadFile("gmod_integration", "sv_config.lua") loadFolder("gmod_integration/languages") +loadFolder("gmod_integration/core/utils") +loadFolder("gmod_integration/core/ui") loadFolder("gmod_integration/core") loadFolder("gmod_integration/modules") loadFolder("gmod_integration") From deac3ef96694185cc1a720fdc0db30242ac1bee8 Mon Sep 17 00:00:00 2001 From: Linventif Date: Wed, 23 Apr 2025 19:20:05 +0000 Subject: [PATCH 08/35] refact: migrate the cl screnshoots overlay --- lua/gmod_integration/core/api/sh_main.lua | 9 +++ .../screenshots/cl_screenshots_overlay.lua | 71 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 lua/gmod_integration/core/api/sh_main.lua create mode 100644 lua/gmod_integration/modules/screenshots/cl_screenshots_overlay.lua diff --git a/lua/gmod_integration/core/api/sh_main.lua b/lua/gmod_integration/core/api/sh_main.lua new file mode 100644 index 0000000..639ce21 --- /dev/null +++ b/lua/gmod_integration/core/api/sh_main.lua @@ -0,0 +1,9 @@ +function gmInte.sendToAPI(endpoint, method, data, onSuccess, onFailed) + gmInte.http.requestAPI({ + ["endpoint"] = endpoint, + ["method"] = method, + ["body"] = data, + ["success"] = onSuccess, + ["failed"] = onFailed + }) +end \ No newline at end of file diff --git a/lua/gmod_integration/modules/screenshots/cl_screenshots_overlay.lua b/lua/gmod_integration/modules/screenshots/cl_screenshots_overlay.lua new file mode 100644 index 0000000..89336cf --- /dev/null +++ b/lua/gmod_integration/modules/screenshots/cl_screenshots_overlay.lua @@ -0,0 +1,71 @@ +hook.Add("HUDPaint", "gmInte:HUD:ShowScreenshotInfo", function() + if !gmInte.showScreenshotInfo then return end + local screenInfo = { + { + txt = "Server ID", + val = gmInte.config.id + }, + { + txt = "SteamID64", + val = LocalPlayer():SteamID64() + }, + { + txt = "Date", + val = os.date("%Y-%m-%d %H:%M:%S") + }, + { + txt = "Position", + val = function() + local pos = LocalPlayer():GetPos() + local newPos = "" + for i = 1, 3 do + newPos = newPos .. math.Round(pos[i]) + if i < 3 then newPos = newPos .. ", " end + end + return newPos + end + }, + { + txt = "Map", + val = game.GetMap() + }, + { + txt = "Ping", + val = LocalPlayer():Ping() + }, + { + txt = "FPS", + val = function() return math.Round(1 / FrameTime()) end + }, + { + txt = "Size", + val = ScrW() .. "x" .. ScrH() + } + } + + local concatInfo = "" + for k, v in pairs(screenInfo) do + local val = v.val + if type(val) == "function" then val = val() end + concatInfo = concatInfo .. v.txt .. ": " .. val + if k < #screenInfo then concatInfo = concatInfo .. " - " end + end + + draw.SimpleText(concatInfo, "DermaDefault", ScrW() / 2, ScrH() - 15, Color(255, 255, 255, 119), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) +end) + +local lastTime = 0 +local frameTime = 0 +local fps = 0 +hook.Add("Think", "gmInte:HUD:CalculateFPS", function() + frameTime = RealTime() - lastTime + lastTime = RealTime() + fps = math.Round(1 / frameTime) +end) + +timer.Create("gmInte:HUD:SendFPS", 5, 0, function() + LocalPlayer().gmIntFPS = fps + gmInte.SendNet("sendFPS", { + ["fps"] = fps + }) +end) \ No newline at end of file From 7401c81a86c4728fa4893997cfd35f52ae24e4c7 Mon Sep 17 00:00:00 2001 From: Linventif Date: Wed, 23 Apr 2025 19:21:31 +0000 Subject: [PATCH 09/35] refact: migrate the admin hook func to open the menu --- .../core/config/cl_admin_menu.lua | 17 ++++ lua/gmod_integration/core/utils/cl_main.lua | 91 +------------------ 2 files changed, 18 insertions(+), 90 deletions(-) diff --git a/lua/gmod_integration/core/config/cl_admin_menu.lua b/lua/gmod_integration/core/config/cl_admin_menu.lua index d538f17..fdb0d62 100644 --- a/lua/gmod_integration/core/config/cl_admin_menu.lua +++ b/lua/gmod_integration/core/config/cl_admin_menu.lua @@ -395,6 +395,23 @@ function gmInte.openConfigMenu(data) end end +function gmInte.openAdminConfig() + if !LocalPlayer():gmIntIsAdmin() then + gmInte.chatAddText(Color(228, 81, 81), gmInte.getTranslation("chat.missing_permissions", "You do not have permission to do this action.")) + return + end + + gmInte.SendNet("getConfig") +end + +function gmInte.showTestConnection(data) + if data && data.id then + gmInte.chatAddText(Color(89, 194, 89), gmInte.getTranslation("chat.authentication_success", "Successfully Authenticated"), Color(255, 255, 255), gmInte.getTranslation("chat.server_link", ", server linked as {1}.", data.name)) + else + gmInte.chatAddText(Color(228, 81, 81), gmInte.getTranslation("chat.authentication_failed", "Failed to Authenticate"), Color(255, 255, 255), gmInte.getTranslation("chat.server_fail", ", check your ID and Token.")) + end +end + concommand.Add("gmod_integration_admin", function() gmInte.SendNet("getConfig") end) concommand.Add("gmi_admin", function() gmInte.SendNet("getConfig") end) hook.Add("OnPlayerChat", "gmInte:OnPlayerChat:AdminCmd", function(ply, strText, bTeamOnly, bPlayerIsDead) diff --git a/lua/gmod_integration/core/utils/cl_main.lua b/lua/gmod_integration/core/utils/cl_main.lua index 9f16fe8..a331e87 100644 --- a/lua/gmod_integration/core/utils/cl_main.lua +++ b/lua/gmod_integration/core/utils/cl_main.lua @@ -13,93 +13,4 @@ function gmInte.chatAddTextFromTable(data) end gmInte.chatAddText(unpack(args)) -end - -function gmInte.showTestConnection(data) - if data && data.id then - gmInte.chatAddText(Color(89, 194, 89), gmInte.getTranslation("chat.authentication_success", "Successfully Authenticated"), Color(255, 255, 255), gmInte.getTranslation("chat.server_link", ", server linked as {1}.", data.name)) - else - gmInte.chatAddText(Color(228, 81, 81), gmInte.getTranslation("chat.authentication_failed", "Failed to Authenticate"), Color(255, 255, 255), gmInte.getTranslation("chat.server_fail", ", check your ID and Token.")) - end -end - -function gmInte.openAdminConfig() - if !LocalPlayer():gmIntIsAdmin() then - gmInte.chatAddText(Color(228, 81, 81), gmInte.getTranslation("chat.missing_permissions", "You do not have permission to do this action.")) - return - end - - gmInte.SendNet("getConfig") -end - -hook.Add("HUDPaint", "gmInte:HUD:ShowScreenshotInfo", function() - if !gmInte.showScreenshotInfo then return end - local screenInfo = { - { - txt = "Server ID", - val = gmInte.config.id - }, - { - txt = "SteamID64", - val = LocalPlayer():SteamID64() - }, - { - txt = "Date", - val = os.date("%Y-%m-%d %H:%M:%S") - }, - { - txt = "Position", - val = function() - local pos = LocalPlayer():GetPos() - local newPos = "" - for i = 1, 3 do - newPos = newPos .. math.Round(pos[i]) - if i < 3 then newPos = newPos .. ", " end - end - return newPos - end - }, - { - txt = "Map", - val = game.GetMap() - }, - { - txt = "Ping", - val = LocalPlayer():Ping() - }, - { - txt = "FPS", - val = function() return math.Round(1 / FrameTime()) end - }, - { - txt = "Size", - val = ScrW() .. "x" .. ScrH() - } - } - - local concatInfo = "" - for k, v in pairs(screenInfo) do - local val = v.val - if type(val) == "function" then val = val() end - concatInfo = concatInfo .. v.txt .. ": " .. val - if k < #screenInfo then concatInfo = concatInfo .. " - " end - end - - draw.SimpleText(concatInfo, "DermaDefault", ScrW() / 2, ScrH() - 15, Color(255, 255, 255, 119), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) -end) - -local lastTime = 0 -local frameTime = 0 -local fps = 0 -hook.Add("Think", "gmInte:HUD:CalculateFPS", function() - frameTime = RealTime() - lastTime - lastTime = RealTime() - fps = math.Round(1 / frameTime) -end) - -timer.Create("gmInte:HUD:SendFPS", 5, 0, function() - LocalPlayer().gmIntFPS = fps - gmInte.SendNet("sendFPS", { - ["fps"] = fps - }) -end) \ No newline at end of file +end \ No newline at end of file From fbf27f4d407292e5b4cc66b794fe2cebce3c5041 Mon Sep 17 00:00:00 2001 From: Linventif Date: Wed, 23 Apr 2025 19:24:04 +0000 Subject: [PATCH 10/35] refact: move errors test con --- .../sh_con.lua => modules/report_errors/sh_erors_test_con.lua} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lua/gmod_integration/{core/utils/sh_con.lua => modules/report_errors/sh_erors_test_con.lua} (100%) diff --git a/lua/gmod_integration/core/utils/sh_con.lua b/lua/gmod_integration/modules/report_errors/sh_erors_test_con.lua similarity index 100% rename from lua/gmod_integration/core/utils/sh_con.lua rename to lua/gmod_integration/modules/report_errors/sh_erors_test_con.lua From 18b904f64aea6fbab7f70354cb139bcbe4ef531d Mon Sep 17 00:00:00 2001 From: Linventif Date: Wed, 23 Apr 2025 19:27:14 +0000 Subject: [PATCH 11/35] feat: add random string generation & generate uuidv4 --- lua/gmod_integration/core/utils/sh_utils.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lua/gmod_integration/core/utils/sh_utils.lua b/lua/gmod_integration/core/utils/sh_utils.lua index ca9c137..22b152d 100644 --- a/lua/gmod_integration/core/utils/sh_utils.lua +++ b/lua/gmod_integration/core/utils/sh_utils.lua @@ -32,4 +32,22 @@ function gmInte.isPrivateIP(ip) if parts[1] == "172" && tonumber(parts[2]) >= 16 && tonumber(parts[2]) <= 31 then return true end if parts[1] == "127" then return true end return false +end + +// Generate Random String +function gmInte.generateRandomString(length) + local charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + local result = "" + math.randomseed(os.time() + #charset * math.random(1, 100)) + for i = 1, length do + local randomIndex = math.random(1, #charset) + result = result .. string.sub(charset, randomIndex, randomIndex) + end + return result +end + +// Generate Random UUIDV4 +function gmInte.generateUUIDV4() + local uuid = string.format("%s-%s-%s-%s-%s", gmInte.generateRandomString(8), gmInte.generateRandomString(4), "4" .. gmInte.generateRandomString(3), gmInte.generateRandomString(4), gmInte.generateRandomString(12)) + return uuid end \ No newline at end of file From 09727be01be871fbe59034d143d2986392b62492 Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 24 Apr 2025 09:21:50 +0000 Subject: [PATCH 12/35] refact: simplify net table --- lua/gmod_integration/core/net/cl_net.lua | 36 ++++++++++-------------- lua/gmod_integration/core/net/sv_net.lua | 36 +++++++++--------------- 2 files changed, 29 insertions(+), 43 deletions(-) diff --git a/lua/gmod_integration/core/net/cl_net.lua b/lua/gmod_integration/core/net/cl_net.lua index 2d1c1b9..cb43a7d 100644 --- a/lua/gmod_integration/core/net/cl_net.lua +++ b/lua/gmod_integration/core/net/cl_net.lua @@ -1,40 +1,34 @@ -local netSend = { - ["ready"] = 0, - ["testConnection"] = 1, - ["getConfig"] = 2, - ["saveConfig"] = 3, - ["takeScreenShot"] = 4, - ["restartMap"] = 5, - ["verifyMe"] = 6, - ["sendFPS"] = 7 -} - function gmInte.SendNet(id, args, func) net.Start("gmIntegration") - net.WriteUInt(netSend[id], 8) + net.WriteString(id) net.WriteString(util.TableToJSON(args || {})) if func then func() end net.SendToServer() end local netReceive = { - [1] = function(data) gmInte.discordSyncChatPly(data) end, - [2] = function(data) gmInte.openConfigMenu(data) end, - [3] = function(data) gmInte.showTestConnection(data) end, - [5] = function(data) + ["wsRelayDiscordChat"] = function(data) gmInte.discordSyncChatPly(data) end, + ["adminConfig"] = function(data) gmInte.openConfigMenu(data) end, + ["testApiConnection"] = function(data) gmInte.showTestConnection(data) end, + ["publicConfig"] = function(data) gmInte.config = table.Merge(gmInte.config, data.config) gmInte.version = data.other.version gmInte.loadTranslations() if gmInte.config.clientBranch != "any" && gmInte.config.clientBranch != BRANCH then gmInte.openWrongBranchPopup() end if !data.other.aprovedCredentials then RunConsoleCommand("gmod_integration_admin") end end, - [6] = function(data) gmInte.chatAddTextFromTable(data) end, - [7] = function() gmInte.openVerifPopup() end, - [8] = function(data) gmInte.config.token = data.token end + ["chatColorMessage"] = function(data) gmInte.chatAddTextFromTable(data) end, + ["openVerifPopup"] = function() gmInte.openVerifPopup() end, + ["savePlayerToken"] = function(data) gmInte.config.token = data.token end } net.Receive("gmIntegration", function() - local id = net.ReadUInt(8) + local id = net.ReadString() local args = util.JSONToTable(net.ReadString()) - if netReceive[id] then netReceive[id](args) end + if !netReceive[id] then return end + netReceive[id](args) + if gmInte.config.debug then + gmInte.log("[net] Received net message: " .. id) + gmInte.log("[net] Data: " .. util.TableToJSON(args)) + end end) \ No newline at end of file diff --git a/lua/gmod_integration/core/net/sv_net.lua b/lua/gmod_integration/core/net/sv_net.lua index 2fa3bb2..41e2053 100644 --- a/lua/gmod_integration/core/net/sv_net.lua +++ b/lua/gmod_integration/core/net/sv_net.lua @@ -1,19 +1,7 @@ util.AddNetworkString("gmIntegration") -local netSend = { - ["wsRelayDiscordChat"] = 1, - ["adminConfig"] = 2, - ["testApiConnection"] = 3, - ["publicConfig"] = 5, - ["chatColorMessage"] = 6, - ["openVerifPopup"] = 7, - ["savePlayerToken"] = 8 -} - -// Send function gmInte.SendNet(id, data, ply, func) - if !netSend[id] then return end net.Start("gmIntegration") - net.WriteUInt(netSend[id], 8) + net.WriteString(id) net.WriteString(util.TableToJSON(data || {})) if func then func() end if ply == nil then @@ -24,27 +12,31 @@ function gmInte.SendNet(id, data, ply, func) end local netReceive = { - [0] = function(ply, data) + ["ready"] = function(ply, data) if ply.gmIntIsReady then return end ply.branch = data.branch hook.Run("gmInte:PlayerReady", ply) end, - [1] = function(ply, data) gmInte.testConnection(ply, data) end, - [2] = function(ply) gmInte.superadminGetConfig(ply) end, - [3] = function(ply, data) gmInte.superadminSetConfig(ply, data) end, - [4] = function(ply) gmInte.takeScreenshot(ply) end, - [5] = function(ply) + ["testConnection"] = function(ply, data) gmInte.testConnection(ply, data) end, + ["getConfig"] = function(ply) gmInte.superadminGetConfig(ply) end, + ["saveConfig"] = function(ply, data) gmInte.superadminSetConfig(ply, data) end, + ["takeScreenShot"] = function(ply) gmInte.takeScreenshot(ply) end, + ["restartMap"] = function(ply) if !ply:gmIntIsAdmin() then return end RunConsoleCommand("changelevel", game.GetMap()) end, - [6] = function(ply) gmInte.verifyPlayer(ply) end, - [7] = function(ply, data) gmInte.sendPlayerToken(ply) end + ["verifyMe"] = function(ply) gmInte.verifyPlayer(ply) end, + ["sendFPS"] = function(ply, data) gmInte.sendPlayerToken(ply) end } net.Receive("gmIntegration", function(len, ply) if !ply || ply && !ply:IsValid() then return end - local id = net.ReadUInt(8) + local id = net.ReadString() local data = util.JSONToTable(net.ReadString() || "{}") if !netReceive[id] then return end netReceive[id](ply, data) + if gmInte.config.debug then + gmInte.log("[net] Received net message: " .. id .. " from " .. (ply && ply:Nick() || "Unknown")) + gmInte.log("[net] Data: " .. util.TableToJSON(data)) + end end) \ No newline at end of file From 60551eee076032303fb68250775e99e44fe91373 Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 24 Apr 2025 09:28:39 +0000 Subject: [PATCH 13/35] fix: forgot to save ply fps + remove a net call every sec --- lua/gmod_integration/core/net/sv_net.lua | 2 +- lua/gmod_integration/core/utils/sh_player_meta.lua | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/gmod_integration/core/net/sv_net.lua b/lua/gmod_integration/core/net/sv_net.lua index 41e2053..654f21b 100644 --- a/lua/gmod_integration/core/net/sv_net.lua +++ b/lua/gmod_integration/core/net/sv_net.lua @@ -26,7 +26,7 @@ local netReceive = { RunConsoleCommand("changelevel", game.GetMap()) end, ["verifyMe"] = function(ply) gmInte.verifyPlayer(ply) end, - ["sendFPS"] = function(ply, data) gmInte.sendPlayerToken(ply) end + ["sendFPS"] = function(ply, data) ply:gmInteSetFPS(fps) end, } net.Receive("gmIntegration", function(len, ply) diff --git a/lua/gmod_integration/core/utils/sh_player_meta.lua b/lua/gmod_integration/core/utils/sh_player_meta.lua index a4d0184..c461125 100644 --- a/lua/gmod_integration/core/utils/sh_player_meta.lua +++ b/lua/gmod_integration/core/utils/sh_player_meta.lua @@ -84,6 +84,12 @@ function ply:gmIntGetFPS() return self.gmIntFPS || 0 end +function ply:gmInteSetFPS(fps) + fps = tonumber(fps || 0) + fps = math.Clamp(fps, 0, 1000) + self.gmIntFPS = fps +end + gmInte.restoreFileCache = gmInte.restoreFileCache || {} function ply:getAdjustedTime() if gmInte.restoreFileCache == nil || gmInte.restoreFileCache.sysTime == nil || gmInte.restoreFileCache.playersList == nil then return 0 end From 8bdf3b4bc0a6bd0a86de4f12a063d603b712892b Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 24 Apr 2025 09:37:16 +0000 Subject: [PATCH 14/35] fix: forgot the data.fps --- lua/gmod_integration/core/net/sv_net.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/gmod_integration/core/net/sv_net.lua b/lua/gmod_integration/core/net/sv_net.lua index 654f21b..84c68bf 100644 --- a/lua/gmod_integration/core/net/sv_net.lua +++ b/lua/gmod_integration/core/net/sv_net.lua @@ -26,7 +26,7 @@ local netReceive = { RunConsoleCommand("changelevel", game.GetMap()) end, ["verifyMe"] = function(ply) gmInte.verifyPlayer(ply) end, - ["sendFPS"] = function(ply, data) ply:gmInteSetFPS(fps) end, + ["sendFPS"] = function(ply, data) ply:gmInteSetFPS(data.fps) end, } net.Receive("gmIntegration", function(len, ply) From 35341414100b62e7805de9c4a800a1ee9666f0ad Mon Sep 17 00:00:00 2001 From: Linventif Date: Sun, 11 May 2025 17:27:30 +0000 Subject: [PATCH 15/35] fix: the darkrp money drop & take logs --- .../modules/money_trackers/darkrp/sv_darkrp.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lua/gmod_integration/modules/money_trackers/darkrp/sv_darkrp.lua b/lua/gmod_integration/modules/money_trackers/darkrp/sv_darkrp.lua index dfaa2ca..9513eb7 100644 --- a/lua/gmod_integration/modules/money_trackers/darkrp/sv_darkrp.lua +++ b/lua/gmod_integration/modules/money_trackers/darkrp/sv_darkrp.lua @@ -28,8 +28,6 @@ function gmInte.postDarkRPPickedUpCheque(plyWriter, plyTarget, price, sucess, en }) end -if DarkRP then - hook.Add("playerDroppedMoney", "gmInte:Player:DarkRPDroppedMoney", function(ply, amount, entity) gmInte.postDarkRPDroppedMoney(ply, amount, entity) end) - hook.Add("playerPickedUpMoney", "gmInte:Player:DarkRPPickedUpMoney", function(ply, price, entity) gmInte.postDarkRPPickedUpMoney(ply, price, entity) end) - hook.Add("playerDroppedCheque", "gmInte:Player:DarkRPPickedUpCheque", function(plyWriter, plyTarget, price, sucess, entity) gmInte.postDarkRPPickedUpCheque(plyWriter, plyTarget, price, sucess, entity) end) -end \ No newline at end of file +hook.Add("playerDroppedMoney", "gmInte:Player:DarkRPDroppedMoney", function(ply, amount, entity) gmInte.postDarkRPDroppedMoney(ply, amount, entity) end) +hook.Add("playerPickedUpMoney", "gmInte:Player:DarkRPPickedUpMoney", function(ply, price, entity) gmInte.postDarkRPPickedUpMoney(ply, price, entity) end) +hook.Add("playerDroppedCheque", "gmInte:Player:DarkRPPickedUpCheque", function(plyWriter, plyTarget, price, sucess, entity) gmInte.postDarkRPPickedUpCheque(plyWriter, plyTarget, price, sucess, entity) end) \ No newline at end of file From 423ca3175a16cc2c2f56635dba710445c44d45d3 Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 22 May 2025 17:34:50 +0000 Subject: [PATCH 16/35] feat: add screenshot title --- .../modules/screenshots/cl_screenshots.lua | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lua/gmod_integration/modules/screenshots/cl_screenshots.lua b/lua/gmod_integration/modules/screenshots/cl_screenshots.lua index ca6db24..5833fc0 100644 --- a/lua/gmod_integration/modules/screenshots/cl_screenshots.lua +++ b/lua/gmod_integration/modules/screenshots/cl_screenshots.lua @@ -1,5 +1,6 @@ local ScreenshotRequested = false local FailAttempts = 0 +local ScreenshotTitle = "" hook.Add("PostRender", "gmInteScreenshot", function() if !ScreenshotRequested then return end local captureData = { @@ -35,6 +36,7 @@ hook.Add("PostRender", "gmInteScreenshot", function() gmInte.http.post("/clients/:steamID64/servers/:serverID/screenshots", { ["player"] = gmInte.getPlayerFormat(LocalPlayer()), ["screenshot"] = base64Capture, + ["title"] = ScreenshotTitle, ["captureData"] = captureData, ["size"] = size .. "KB" }, function(code, body) gmInte.chatAddText(Color(255, 130, 92), gmInte.getTranslation("chat.screenshot.sent", "Screenshot sent to Discord.")) end, function(code, body) @@ -54,16 +56,26 @@ function gmInte.takeScreenShot() end) end -concommand.Add("gmi_screen", gmInte.takeScreenShot) -concommand.Add("gmod_integration_screen", gmInte.takeScreenShot) +local function extractTitleFromCmd(ply, cmd, args) + if !args[1] then + ScreenshotTitle = "" + else + ScreenshotTitle = table.concat(args, " ") + end + + gmInte.takeScreenShot() +end + +concommand.Add("gmi_screen", extractTitleFromCmd) +concommand.Add("gmod_integration_screen", extractTitleFromCmd) hook.Add("OnPlayerChat", "gmInteChatCommands", function(ply, text, teamChat, isDead) if ply != LocalPlayer() then return end - text = string.lower(text) - text = string.sub(text, 2) - if text == "screen" then - gmInte.takeScreenShot() - return true - end + if string.len(text) < 7 then return end + local cmdPrefix = string.sub(text, 1, 1) + local args = string.Explode(" ", string.sub(text, 2)) + if args[1] != "screen" && args[1] != "screenshot" then return end + ScreenshotTitle = table.concat(args, " ", 2) + gmInte.takeScreenShot() end) local contextMenuOpen = false From b322f58a70dd2a4c54f3426ab8c6a97e47b014a2 Mon Sep 17 00:00:00 2001 From: Linventif Date: Sat, 24 May 2025 17:28:50 +0000 Subject: [PATCH 17/35] fix: token not send to client --- lua/gmod_integration/core/security/sv_tokens.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/gmod_integration/core/security/sv_tokens.lua b/lua/gmod_integration/core/security/sv_tokens.lua index 5ea56ac..665506e 100644 --- a/lua/gmod_integration/core/security/sv_tokens.lua +++ b/lua/gmod_integration/core/security/sv_tokens.lua @@ -37,5 +37,5 @@ function gmInte.sendPlayerToken(ply) end) end -hook.Add("gmInte:PlayerReady", "gmInte:Verif:PlayerReady", function(ply) gmInte.sendPlayerToken(ply) end) +hook.Add("gmInte:PlayerReady", "gmInte:PlayerReady:SendToken", function(ply) gmInte.sendPlayerToken(ply) end) hook.Add("Initialize", "gmInte:Server:Initialize:GetPublicToken", function() timer.Simple(1, function() gmInte.getPublicServerToken(function(publicToken) gmInte.log("Server Public Token Received: " .. publicToken) end) end) end) \ No newline at end of file From 0db418ef4a2664dc029076714924d1c407c58f7c Mon Sep 17 00:00:00 2001 From: Linventif Date: Mon, 26 May 2025 00:13:51 +0000 Subject: [PATCH 18/35] refact: change the name of sv_websocket --- .../core/api/{sv__websocket.lua => sv_websocket.lua} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lua/gmod_integration/core/api/{sv__websocket.lua => sv_websocket.lua} (100%) diff --git a/lua/gmod_integration/core/api/sv__websocket.lua b/lua/gmod_integration/core/api/sv_websocket.lua similarity index 100% rename from lua/gmod_integration/core/api/sv__websocket.lua rename to lua/gmod_integration/core/api/sv_websocket.lua From 6eebe5f165f70cae170a9a645216d82b773fdc46 Mon Sep 17 00:00:00 2001 From: Linventif Date: Mon, 26 May 2025 00:18:46 +0000 Subject: [PATCH 19/35] refact: remove materials importer --- lua/autorun/gmod_integration.lua | 1 - lua/gmod_integration/core/ui/cl_materials.lua | 43 ------------------- 2 files changed, 44 deletions(-) delete mode 100644 lua/gmod_integration/core/ui/cl_materials.lua diff --git a/lua/autorun/gmod_integration.lua b/lua/autorun/gmod_integration.lua index e139758..b1daaaf 100644 --- a/lua/autorun/gmod_integration.lua +++ b/lua/autorun/gmod_integration.lua @@ -2,7 +2,6 @@ if game.SinglePlayer() then return print("Gmod Integration is not supported in S gmInte = gmInte || {} gmInte.version = "0.5.0" gmInte.config = {} -gmInte.materials = {} local function loadConfig() RunConsoleCommand("sv_hibernate_think", "1") if !file.Exists("gm_integration", "DATA") || !file.Exists("gm_integration/config.json", "DATA") then diff --git a/lua/gmod_integration/core/ui/cl_materials.lua b/lua/gmod_integration/core/ui/cl_materials.lua deleted file mode 100644 index c931687..0000000 --- a/lua/gmod_integration/core/ui/cl_materials.lua +++ /dev/null @@ -1,43 +0,0 @@ -local ImageCache = {} -function gmInte.createImgurMaterials(materials, addon_var, folder, name) - if !file.Exists(folder, "DATA") then file.CreateDir(folder) end - local function getMatFromUrl(url, id) - materials[id] = Material("nil") - if file.Exists(folder .. "/" .. id .. ".png", "DATA") && !gmInte.config.redownloadMaterials then - addon_var[id] = Material("../data/" .. folder .. "/" .. id .. ".png", "noclamp smooth") - gmInte.log("materials", name .. " - Image Loaded - " .. id .. ".png") - return - end - - http.Fetch(url, function(body) - file.Write(folder .. "/" .. id .. ".png", body) - addon_var[id] = Material("../data/" .. folder .. "/" .. id .. ".png", "noclamp smooth") - ImageCache[table.Count(ImageCache) + 1] = { - ["folder"] = folder, - ["addon_var"] = addon_var, - ["id"] = id - } - - gmInte.log("materials", name .. " - Image Downloaded - " .. id .. ".png") - end) - end - - for k, v in pairs(materials) do - getMatFromUrl("https://i.imgur.com/" .. v .. ".png", k) - end -end - -function gmInte.redowloadMaterials() - for k, v in pairs(ImageCache) do - v.addon_var[v.id] = Material("../data/" .. v.folder .. "/" .. v.id .. ".png", "noclamp smooth") - gmInte.log("materials", v.name .. " - Image Redownloaded - " .. v.id .. ".png") - end -end - -concommand.Add("gmod_integration_reload_materials", gmInte.redowloadMaterials) -concommand.Add("gmi_reload_materials", gmInte.redowloadMaterials) -local materialsList = { - ["logo"] = "y3Mypbn" -} - -gmInte.createImgurMaterials(materialsList, gmInte.materials, "gmod_integration/material", "Gmod Integration") \ No newline at end of file From f7dbb0250d1195863a2bf8618fe54a7d515fbc4b Mon Sep 17 00:00:00 2001 From: Linventif Date: Mon, 26 May 2025 00:33:20 +0000 Subject: [PATCH 20/35] refact: extract module code into their own file --- .../core/utils/sh_player_adjusted_time.lua | 82 ++++++++++ .../core/utils/sh_player_custom_values.lua | 57 +++++++ .../core/utils/sh_player_meta.lua | 145 +----------------- .../players_filter_link_account/sh_main.lua | 4 + 4 files changed, 144 insertions(+), 144 deletions(-) create mode 100644 lua/gmod_integration/core/utils/sh_player_adjusted_time.lua create mode 100644 lua/gmod_integration/core/utils/sh_player_custom_values.lua create mode 100644 lua/gmod_integration/modules/players_filter_link_account/sh_main.lua diff --git a/lua/gmod_integration/core/utils/sh_player_adjusted_time.lua b/lua/gmod_integration/core/utils/sh_player_adjusted_time.lua new file mode 100644 index 0000000..01d3820 --- /dev/null +++ b/lua/gmod_integration/core/utils/sh_player_adjusted_time.lua @@ -0,0 +1,82 @@ +local ply = FindMetaTable("Player") +function ply:gmIntGetTimeLastTeamChange() + return self.gmIntTimeLastTeamChange || RealTime() +end + +function ply:gmInteResetTimeLastTeamChange() + self.gmIntTimeLastTeamChange = RealTime() +end + +gmInte.restoreFileCache = gmInte.restoreFileCache || {} +function ply:getAdjustedTime() + if gmInte.restoreFileCache == nil || gmInte.restoreFileCache.sysTime == nil || gmInte.restoreFileCache.playersList == nil then return 0 end + if SERVER then + if table.IsEmpty(gmInte.restoreFileCache) then + if file.Exists("gm_integration/player_before_map_change.json", "DATA") then + gmInte.restoreFileCache = util.JSONToTable(file.Read("gm_integration/player_before_map_change.json", "DATA")) + else + return 0 + end + end + else + if table.IsEmpty(gmInte.restoreFileCache) then + if file.Exists("gmod_integration/player_before_map_change.json", "DATA") then + gmInte.restoreFileCache = util.JSONToTable(file.Read("gmod_integration/player_before_map_change.json", "DATA")) + else + return 0 + end + + gmInte.restoreFileCache = gmInte.restoreFileCache[gmInte.config.id] + end + end + + if !gmInte.restoreFileCache.sysTime || !gmInte.restoreFileCache.playersList then return 0 end + if (gmInte.restoreFileCache.sysTime + 60 * 5) < (os.time() - self:gmIntGetConnectTime()) then return 0 end + if !gmInte.restoreFileCache.playersList[self:SteamID()] then return 0 end + return gmInte.restoreFileCache.playersList[self:SteamID()].connectTime || 0 +end + +if SERVER then + gameevent.Listen("player_connect") + hook.Add("player_connect", "gmInte:Player:Connect:RemoveRestore", function(data) + if table.IsEmpty(gmInte.restoreFileCache) then + if file.Exists("gm_integration/player_before_map_change.json", "DATA") then + gmInte.restoreFileCache = util.JSONToTable(file.Read("gm_integration/player_before_map_change.json", "DATA")) + else + return + end + end + + if gmInte.restoreFileCache.playersList && gmInte.restoreFileCache.playersList[data.networkid] then + gmInte.restoreFileCache.playersList[data.networkid] = nil + file.Write("gm_integration/player_before_map_change.json", util.TableToJSON(gmInte.restoreFileCache, true)) + end + end) +end + +local function saveTimeToLocal() + local dataToSave = { + ["version"] = "1.0", + ["serverID"] = gmInte.config.id, + ["playersList"] = {}, + ["sysTime"] = os.time() + } + + if SERVER then + for _, ply in ipairs(player.GetAll()) do + dataToSave.playersList[ply:SteamID()] = gmInte.getPlayerFormat(ply) + end + + if !file.Exists("gm_integration", "DATA") then file.CreateDir("gm_integration") end + file.Write("gm_integration/player_before_map_change.json", util.TableToJSON(dataToSave, true)) + else + dataToSave.playersList[LocalPlayer():SteamID()] = gmInte.getPlayerFormat(LocalPlayer()) + local oldData = {} + if file.Exists("gmod_integration/player_before_map_change.json", "DATA") then oldData = util.JSONToTable(file.Read("gmod_integration/player_before_map_change.json", "DATA")) end + oldData[gmInte.config.id] = dataToSave + file.Write("gmod_integration/player_before_map_change.json", util.TableToJSON(oldData, true)) + end +end + +hook.Add("ShutDown", "gmInte:Server:ShutDown:SavePlayer", saveTimeToLocal) +hook.Add("GMI:SaveBeforeCrash", "gmInte:Server:BeforeCrash:SavePlayers", saveTimeToLocal) \ No newline at end of file diff --git a/lua/gmod_integration/core/utils/sh_player_custom_values.lua b/lua/gmod_integration/core/utils/sh_player_custom_values.lua new file mode 100644 index 0000000..88454d8 --- /dev/null +++ b/lua/gmod_integration/core/utils/sh_player_custom_values.lua @@ -0,0 +1,57 @@ +local ply = FindMetaTable("Player") +function ply:gmIntSetCustomValue(key, value) + self.gmIntCustomValues = self.gmIntCustomValues || {} + self.gmIntCustomValues[key] = value +end + +function ply:gmIntGetCustomValue(key) + return self.gmIntCustomValues && self.gmIntCustomValues[key] +end + +function ply:gmIntRemoveCustomValue(key) + if self.gmIntCustomValues then self.gmIntCustomValues[key] = nil end +end + +local function getCustomCompatability(ply) + local values = {} + // DarkRP + if DarkRP then + values.money = ply:getDarkRPVar("money") + values.job = ply:getDarkRPVar("job") + end + + // GUI Level System + if GUILevelSystem then + values.level = ply:GetLevel() + values.xp = ply:GetXP() + end + + // Pointshop 2 + if Pointshop2 && ply.PS2_Wallet then + values.ps2Points = ply.PS2_Wallet.points + values.ps2PremiumPoints = ply.PS2_Wallet.premiumPoints + end + + if CH_ATM && SERVER then values.bank = CH_ATM.GetMoneyBankAccount(ply) end + return values +end + +local function getCustomValues(ply) + local values = {} + // Get compatability values + for key, value in pairs(getCustomCompatability(ply)) do + values[key] = value + end + + // Get custom values or overwrite compatability values + if ply.gmIntCustomValues then + for key, value in pairs(ply.gmIntCustomValues) do + values[key] = value + end + end + return values +end + +function ply:gmIntGetCustomValues() + return getCustomValues(self) +end \ No newline at end of file diff --git a/lua/gmod_integration/core/utils/sh_player_meta.lua b/lua/gmod_integration/core/utils/sh_player_meta.lua index c461125..371cc68 100644 --- a/lua/gmod_integration/core/utils/sh_player_meta.lua +++ b/lua/gmod_integration/core/utils/sh_player_meta.lua @@ -3,83 +3,14 @@ function ply:gmIntGetConnectTime() return self.gmIntTimeConnect || 0 end -function ply:gmIntIsVerified() - return self.gmIntVerified || false -end - -function ply:gmIntGetTimeLastTeamChange() - return self.gmIntTimeLastTeamChange || RealTime() -end - -function ply:gmInteResetTimeLastTeamChange() - self.gmIntTimeLastTeamChange = RealTime() -end - function ply:gmInteGetBranch() return CLIENT && BRANCH || self.branch || "unknown" end -function ply:gmIntSetCustomValue(key, value) - self.gmIntCustomValues = self.gmIntCustomValues || {} - self.gmIntCustomValues[key] = value -end - function ply:gmIntIsAdmin() return gmInte.config.adminRank[self:GetUserGroup()] || false end -function ply:gmIntGetCustomValue(key) - return self.gmIntCustomValues && self.gmIntCustomValues[key] -end - -function ply:gmIntRemoveCustomValue(key) - if self.gmIntCustomValues then self.gmIntCustomValues[key] = nil end -end - -local function getCustomCompatability(ply) - local values = {} - // DarkRP - if DarkRP then - values.money = ply:getDarkRPVar("money") - values.job = ply:getDarkRPVar("job") - end - - // GUI Level System - if GUILevelSystem then - values.level = ply:GetLevel() - values.xp = ply:GetXP() - end - - // Pointshop 2 - if Pointshop2 && ply.PS2_Wallet then - values.ps2Points = ply.PS2_Wallet.points - values.ps2PremiumPoints = ply.PS2_Wallet.premiumPoints - end - - if CH_ATM && SERVER then values.bank = CH_ATM.GetMoneyBankAccount(ply) end - return values -end - -local function getCustomValues(ply) - local values = {} - // Get compatability values - for key, value in pairs(getCustomCompatability(ply)) do - values[key] = value - end - - // Get custom values or overwrite compatability values - if ply.gmIntCustomValues then - for key, value in pairs(ply.gmIntCustomValues) do - values[key] = value - end - end - return values -end - -function ply:gmIntGetCustomValues() - return getCustomValues(self) -end - function ply:gmIntGetFPS() return self.gmIntFPS || 0 end @@ -88,78 +19,4 @@ function ply:gmInteSetFPS(fps) fps = tonumber(fps || 0) fps = math.Clamp(fps, 0, 1000) self.gmIntFPS = fps -end - -gmInte.restoreFileCache = gmInte.restoreFileCache || {} -function ply:getAdjustedTime() - if gmInte.restoreFileCache == nil || gmInte.restoreFileCache.sysTime == nil || gmInte.restoreFileCache.playersList == nil then return 0 end - if SERVER then - if table.IsEmpty(gmInte.restoreFileCache) then - if file.Exists("gm_integration/player_before_map_change.json", "DATA") then - gmInte.restoreFileCache = util.JSONToTable(file.Read("gm_integration/player_before_map_change.json", "DATA")) - else - return 0 - end - end - else - if table.IsEmpty(gmInte.restoreFileCache) then - if file.Exists("gmod_integration/player_before_map_change.json", "DATA") then - gmInte.restoreFileCache = util.JSONToTable(file.Read("gmod_integration/player_before_map_change.json", "DATA")) - else - return 0 - end - - gmInte.restoreFileCache = gmInte.restoreFileCache[gmInte.config.id] - end - end - - if !gmInte.restoreFileCache.sysTime || !gmInte.restoreFileCache.playersList then return 0 end - if (gmInte.restoreFileCache.sysTime + 60 * 5) < (os.time() - self:gmIntGetConnectTime()) then return 0 end - if !gmInte.restoreFileCache.playersList[self:SteamID()] then return 0 end - return gmInte.restoreFileCache.playersList[self:SteamID()].connectTime || 0 -end - -if SERVER then - gameevent.Listen("player_connect") - hook.Add("player_connect", "gmInte:Player:Connect:RemoveRestore", function(data) - if table.IsEmpty(gmInte.restoreFileCache) then - if file.Exists("gm_integration/player_before_map_change.json", "DATA") then - gmInte.restoreFileCache = util.JSONToTable(file.Read("gm_integration/player_before_map_change.json", "DATA")) - else - return - end - end - - if gmInte.restoreFileCache.playersList && gmInte.restoreFileCache.playersList[data.networkid] then - gmInte.restoreFileCache.playersList[data.networkid] = nil - file.Write("gm_integration/player_before_map_change.json", util.TableToJSON(gmInte.restoreFileCache, true)) - end - end) -end - -local function saveTimeToLocal() - local dataToSave = { - ["version"] = "1.0", - ["serverID"] = gmInte.config.id, - ["playersList"] = {}, - ["sysTime"] = os.time() - } - - if SERVER then - for _, ply in ipairs(player.GetAll()) do - dataToSave.playersList[ply:SteamID()] = gmInte.getPlayerFormat(ply) - end - - if !file.Exists("gm_integration", "DATA") then file.CreateDir("gm_integration") end - file.Write("gm_integration/player_before_map_change.json", util.TableToJSON(dataToSave, true)) - else - dataToSave.playersList[LocalPlayer():SteamID()] = gmInte.getPlayerFormat(LocalPlayer()) - local oldData = {} - if file.Exists("gmod_integration/player_before_map_change.json", "DATA") then oldData = util.JSONToTable(file.Read("gmod_integration/player_before_map_change.json", "DATA")) end - oldData[gmInte.config.id] = dataToSave - file.Write("gmod_integration/player_before_map_change.json", util.TableToJSON(oldData, true)) - end -end - -hook.Add("ShutDown", "gmInte:Server:ShutDown:SavePlayer", saveTimeToLocal) -hook.Add("GMI:SaveBeforeCrash", "gmInte:Server:BeforeCrash:SavePlayers", saveTimeToLocal) \ No newline at end of file +end \ No newline at end of file diff --git a/lua/gmod_integration/modules/players_filter_link_account/sh_main.lua b/lua/gmod_integration/modules/players_filter_link_account/sh_main.lua new file mode 100644 index 0000000..ee2b7bd --- /dev/null +++ b/lua/gmod_integration/modules/players_filter_link_account/sh_main.lua @@ -0,0 +1,4 @@ +local ply = FindMetaTable("Player") +function ply:gmIntIsVerified() + return self.gmIntVerified || false +end \ No newline at end of file From 6ceeaf15359bded0c2af8a54dcaaae752fff821e Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 27 May 2025 18:55:21 +0000 Subject: [PATCH 21/35] refact: remove cmd refresh --- lua/gmod_integration/core/config/sv_con.lua | 2 -- lua/gmod_integration/core/config/sv_settings.lua | 6 ------ 2 files changed, 8 deletions(-) diff --git a/lua/gmod_integration/core/config/sv_con.lua b/lua/gmod_integration/core/config/sv_con.lua index 28928df..09e7698 100644 --- a/lua/gmod_integration/core/config/sv_con.lua +++ b/lua/gmod_integration/core/config/sv_con.lua @@ -3,7 +3,6 @@ local conFuncs = { ["set-setting"] = function(args) gmInte.saveSetting(args[2], args[3]) end, ["show-settings"] = function() PrintTable(gmInte.config) end, ["try"] = function() gmInte.tryConfig() end, - ["refresh"] = function() gmInte.refreshSettings() end, ["get-server-id"] = function() print(gmInte.config.id || "none") end, ["export-warns"] = function() hook.Run("GmodIntegration:ExportWarns") end } @@ -18,7 +17,6 @@ local function cmdExecuted(ply, cmd, args) print("set-setting ") print("show-settings") print("try") - print("refresh") print("get-server-id") print("export-warns") end diff --git a/lua/gmod_integration/core/config/sv_settings.lua b/lua/gmod_integration/core/config/sv_settings.lua index 6defd39..5279d37 100644 --- a/lua/gmod_integration/core/config/sv_settings.lua +++ b/lua/gmod_integration/core/config/sv_settings.lua @@ -42,12 +42,6 @@ function gmInte.testConnection(ply) gmInte.http.get("/servers/:serverID", function(code, body) if ply then gmInte.SendNet("testApiConnection", body, ply) end end, function(code, body) if ply then gmInte.SendNet("testApiConnection", body, ply) end end) end -function gmInte.refreshSettings() - gmInte.config = util.JSONToTable(file.Read("gm_integration/config.json", "DATA")) - gmInte.log("Settings Refreshed") - gmInte.tryConfig() -end - function gmInte.superadminGetConfig(ply) if !ply:IsValid() || !ply:IsPlayer(ply) || !ply:gmIntIsAdmin() then return end gmInte.config.websocket = GWSockets && true || false From de480a89348818085aecd1fb8933ebf034ff271c Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 27 May 2025 19:15:27 +0000 Subject: [PATCH 22/35] feat: only log timestamp on debug --- lua/gmod_integration/core/utils/sh_utils.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lua/gmod_integration/core/utils/sh_utils.lua b/lua/gmod_integration/core/utils/sh_utils.lua index 22b152d..4b735d4 100644 --- a/lua/gmod_integration/core/utils/sh_utils.lua +++ b/lua/gmod_integration/core/utils/sh_utils.lua @@ -1,24 +1,29 @@ +local function getTimeStamp() + if !gmInte.config.debug then return "" end + return os.date("[%Y-%m-%d %H:%M:%S]") +end + function gmInte.log(msg, debug) if debug && !gmInte.config.debug then return end - print("[" .. os.date("%Y-%m-%d %H:%M:%S") .. "] [Gmod Integration] " .. msg) + print(getTimeStamp() .. " [Gmod Integration] " .. msg) end // Log Error 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) + print(getTimeStamp() .. " [Gmod Integration] [ERROR] " .. msg) end // Log Warning function gmInte.logWarning(msg, debug) if debug && !gmInte.config.debug then return end - print("[" .. os.date("%Y-%m-%d %H:%M:%S") .. "] [Gmod Integration] [WARNING] " .. msg) + print(getTimeStamp() .. " [Gmod Integration] [WARNING] " .. msg) end // Log Hint function gmInte.logHint(msg, debug) if debug && !gmInte.config.debug then return end - print("[" .. os.date("%Y-%m-%d %H:%M:%S") .. "] [Gmod Integration] [HINT] " .. msg) + print(getTimeStamp() .. " [Gmod Integration] [HINT] " .. msg) end // Is Private IP From 39db1436b2c0079de62f58b3c0b9276b61fcacab Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 27 May 2025 19:32:12 +0000 Subject: [PATCH 23/35] feat: add gmInte.config.logTimestamp --- lua/autorun/gmod_integration.lua | 16 ++++++++++++++-- .../core/config/cl_admin_menu.lua | 15 +++++++++++++++ lua/gmod_integration/core/config/sv_settings.lua | 3 ++- lua/gmod_integration/core/utils/sh_utils.lua | 10 +++++----- lua/gmod_integration/sv_config.lua | 1 + 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lua/autorun/gmod_integration.lua b/lua/autorun/gmod_integration.lua index b1daaaf..dba6882 100644 --- a/lua/autorun/gmod_integration.lua +++ b/lua/autorun/gmod_integration.lua @@ -2,13 +2,23 @@ if game.SinglePlayer() then return print("Gmod Integration is not supported in S gmInte = gmInte || {} gmInte.version = "0.5.0" gmInte.config = {} +gmInte.useDataConfig = true +function gmInte.simpleLog(msg, debug) + print(" | " .. os.date(gmInte.config.logTimestamp || "%Y-%m-%d %H:%M:%S") .. " | Gmod Integration | " .. msg) +end + local function loadConfig() RunConsoleCommand("sv_hibernate_think", "1") if !file.Exists("gm_integration", "DATA") || !file.Exists("gm_integration/config.json", "DATA") then file.CreateDir("gm_integration") file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true)) else - if gmInte.config.id && gmInte.config.id != "" then return end + if gmInte.config.id && gmInte.config.id != "" then + gmInte.useDataConfig = false + timer.Simple(1, function() gmInte.simpleLog("Using Data Config | This is not recommended, please revert change and use ig cmd !gmi to edit your config", true) end) + return + end + local oldConfig = util.JSONToTable(file.Read("gm_integration/config.json", "DATA")) if !oldConfig.version || (oldConfig.version < gmInte.version) then table.Merge(gmInte.config, oldConfig) @@ -17,6 +27,8 @@ local function loadConfig() else gmInte.config = oldConfig end + + gmInte.simpleLog("Using Data Config | Data config loaded from data/gm_integration/config.json") end end @@ -25,7 +37,6 @@ local function loadFile(folder, fileName) local path = folder .. "/" .. fileName if loadedFiles[path] then return end loadedFiles[path] = true - print(" | Loading File | " .. path) if string.StartWith(fileName, "cl_") then if SERVER then AddCSLuaFile(path) @@ -40,6 +51,7 @@ local function loadFile(folder, fileName) end if fileName == "sv_config.lua" then loadConfig() end + gmInte.simpleLog("File Loaded | " .. path) end local function loadFolder(folder) diff --git a/lua/gmod_integration/core/config/cl_admin_menu.lua b/lua/gmod_integration/core/config/cl_admin_menu.lua index fdb0d62..ab4ae5b 100644 --- a/lua/gmod_integration/core/config/cl_admin_menu.lua +++ b/lua/gmod_integration/core/config/cl_admin_menu.lua @@ -222,6 +222,21 @@ function gmInte.openConfigMenu(data) ["onEditDelay"] = 0.5, ["category"] = gmInte.getTranslation("admin.advanced", "Advanced") }, + { + ["id"] = "logTimestamp", + ["label"] = gmInte.getTranslation("admin.internal_log_format", "Internal Log Format"), + ["description"] = gmInte.getTranslation("admin.internal_log_format_description", "The timestamp format of the logs."), + ["type"] = "textEntry", + ["resetIfEmpty"] = true, + ["defaultValue"] = "%Y-%m-%d %H:%M:%S", + ["value"] = function(setting, value) return value end, + ["onEdit"] = function(setting, value) + if !value || value == "" then return end + saveConfig(setting, value) + end, + ["onEditDelay"] = 0.5, + ["category"] = gmInte.getTranslation("admin.advanced", "Advanced") + }, } local buttonsInfo = { diff --git a/lua/gmod_integration/core/config/sv_settings.lua b/lua/gmod_integration/core/config/sv_settings.lua index 5279d37..5e9bafe 100644 --- a/lua/gmod_integration/core/config/sv_settings.lua +++ b/lua/gmod_integration/core/config/sv_settings.lua @@ -58,7 +58,8 @@ function gmInte.publicGetConfig(ply) ["websocketFQDN"] = gmInte.config.websocketFQDN, ["adminRank"] = gmInte.config.adminRank, ["language"] = gmInte.config.language, - ["clientBranch"] = gmInte.config.clientBranch + ["clientBranch"] = gmInte.config.clientBranch, + ["logTimestamp"] = gmInte.config.logTimestamp }, ["other"] = { ["aprovedCredentials"] = gmInte.aprovedCredentials, diff --git a/lua/gmod_integration/core/utils/sh_utils.lua b/lua/gmod_integration/core/utils/sh_utils.lua index 4b735d4..962b89a 100644 --- a/lua/gmod_integration/core/utils/sh_utils.lua +++ b/lua/gmod_integration/core/utils/sh_utils.lua @@ -1,29 +1,29 @@ local function getTimeStamp() if !gmInte.config.debug then return "" end - return os.date("[%Y-%m-%d %H:%M:%S]") + return os.date(gmInte.config.logTimestamp || "%Y-%m-%d %H:%M:%S") end function gmInte.log(msg, debug) if debug && !gmInte.config.debug then return end - print(getTimeStamp() .. " [Gmod Integration] " .. msg) + print(getTimeStamp() .. " | Gmod Integration | " .. msg) end // Log Error function gmInte.logError(msg, debug) if debug && !gmInte.config.debug then return end - print(getTimeStamp() .. " [Gmod Integration] [ERROR] " .. msg) + print(getTimeStamp() .. " | Gmod Integration | ERROR | " .. msg) end // Log Warning function gmInte.logWarning(msg, debug) if debug && !gmInte.config.debug then return end - print(getTimeStamp() .. " [Gmod Integration] [WARNING] " .. msg) + print(getTimeStamp() .. " | Gmod Integration | WARNING | " .. msg) end // Log Hint function gmInte.logHint(msg, debug) if debug && !gmInte.config.debug then return end - print(getTimeStamp() .. " [Gmod Integration] [HINT] " .. msg) + print(getTimeStamp() .. " | Gmod Integration | HINT | " .. msg) end // Is Private IP diff --git a/lua/gmod_integration/sv_config.lua b/lua/gmod_integration/sv_config.lua index b4b06ab..0818e11 100644 --- a/lua/gmod_integration/sv_config.lua +++ b/lua/gmod_integration/sv_config.lua @@ -38,6 +38,7 @@ gmInte.config.clientBranch = "any" // The branch of the addon that the clients s gmInte.config.supportLink = "" // The link of your support (shown when a player do not have the requiments to join the server) gmInte.config.maintenance = false // If true, the addon will only allow the players with the "gmod-integration.maintenance" permission to join the server gmInte.config.language = "en" // The language of the addon (en, fr, de, es, it, tr, ru) +gmInte.config.logTimestamp = "%H:%M:%S" // The timestamp format of the logs gmInte.config.adminRank = { // How can edit the configuration of the addon / bypass the maintenance mode ["superadmin"] = true, From c98afda1d3002d0c635a7deb19978c9b722d35a8 Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 27 May 2025 19:40:46 +0000 Subject: [PATCH 24/35] feat: don't open ig config if sv_config.lua has been edited --- .../core/config/cl_admin_menu.lua | 37 +++++++++++++++++++ .../core/config/sv_settings.lua | 5 +++ lua/gmod_integration/core/net/cl_net.lua | 3 +- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/lua/gmod_integration/core/config/cl_admin_menu.lua b/lua/gmod_integration/core/config/cl_admin_menu.lua index ab4ae5b..aa0f4ec 100644 --- a/lua/gmod_integration/core/config/cl_admin_menu.lua +++ b/lua/gmod_integration/core/config/cl_admin_menu.lua @@ -13,6 +13,43 @@ local colorTable = { ["buttonTextHover"] = Color(255, 255, 255, 255), } +// function to open a msg info say in game config has been disabled because default sv_config.lua has been edited +function gmInte.openDisabledConfig() + local frame = vgui.Create("DFrame") + frame:SetSize(400, 120) + frame:Center() + frame:SetTitle(gmInte.getFrameName(gmInte.getTranslation("admin.config_disabled", "Config Disabled"))) + frame:SetDraggable(true) + frame:ShowCloseButton(true) + frame:MakePopup() + gmInte.applyPaint(frame) + local messagePanel = vgui.Create("DPanel", frame) + messagePanel:Dock(TOP) + messagePanel:SetSize(300, 40) + messagePanel:DockMargin(10, 0, 10, 10) + messagePanel:SetBackgroundColor(Color(0, 0, 0, 0)) + local messageLabel = vgui.Create("DLabel", messagePanel) + messageLabel:Dock(FILL) + messageLabel:SetText(gmInte.getTranslation("admin.config_disabled_description", "The config has been disabled because the default sv_config.lua has been edited.\nPlease restore the default sv_config.lua to enable the config again.")) + messageLabel:SetContentAlignment(5) + messageLabel:SetWrap(true) + local buttonGrid = vgui.Create("DGrid", frame) + buttonGrid:Dock(BOTTOM) + buttonGrid:DockMargin(5, 10, 5, 5) + buttonGrid:SetCols(1) + buttonGrid:SetColWide(frame:GetWide() - 10) + buttonGrid:SetRowHeight(35) + local button = vgui.Create("DButton") + button:SetText(gmInte.getTranslation("admin.ok", "OK")) + button.DoClick = function() frame:Close() end + button:SetSize(buttonGrid:GetColWide() - 10, buttonGrid:GetRowHeight()) + gmInte.applyPaint(button) + buttonGrid:AddItem(button) + frame.OnClose = function() gmInte.openAdminPanel = false end + frame.OnRemove = function() gmInte.openAdminPanel = false end + frame.OnKeyCodePressed = function(self, key) if key == KEY_ESCAPE then self:Close() end end +end + function gmInte.needRestart() local frame = vgui.Create("DFrame") frame:SetSize(400, 120) diff --git a/lua/gmod_integration/core/config/sv_settings.lua b/lua/gmod_integration/core/config/sv_settings.lua index 5e9bafe..595ffa3 100644 --- a/lua/gmod_integration/core/config/sv_settings.lua +++ b/lua/gmod_integration/core/config/sv_settings.lua @@ -44,6 +44,11 @@ end function gmInte.superadminGetConfig(ply) if !ply:IsValid() || !ply:IsPlayer(ply) || !ply:gmIntIsAdmin() then return end + if !gmInte.useDataConfig then + gmInte.SendNet("notEditableConfig", {}, ply) + return + end + gmInte.config.websocket = GWSockets && true || false gmInte.SendNet("adminConfig", gmInte.config, ply) end diff --git a/lua/gmod_integration/core/net/cl_net.lua b/lua/gmod_integration/core/net/cl_net.lua index cb43a7d..17a78c8 100644 --- a/lua/gmod_integration/core/net/cl_net.lua +++ b/lua/gmod_integration/core/net/cl_net.lua @@ -19,7 +19,8 @@ local netReceive = { end, ["chatColorMessage"] = function(data) gmInte.chatAddTextFromTable(data) end, ["openVerifPopup"] = function() gmInte.openVerifPopup() end, - ["savePlayerToken"] = function(data) gmInte.config.token = data.token end + ["savePlayerToken"] = function(data) gmInte.config.token = data.token end, + ["notEditableConfig"] = function() gmInte.openDisabledConfig() end, } net.Receive("gmIntegration", function() From 7442efd6f5f015139ad937dc2e45f0a3e4c00db8 Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 27 May 2025 19:50:28 +0000 Subject: [PATCH 25/35] feat: add missing translation --- lua/gmod_integration/languages/sh_de.lua | 5 +- lua/gmod_integration/languages/sh_en.lua | 4 +- lua/gmod_integration/languages/sh_es.lua | 5 +- lua/gmod_integration/languages/sh_fr.lua | 5 +- lua/gmod_integration/languages/sh_it.lua | 5 +- lua/gmod_integration/languages/sh_nl.lua | 99 ++++++++++++------------ lua/gmod_integration/languages/sh_pl.lua | 5 +- lua/gmod_integration/languages/sh_ru.lua | 5 +- lua/gmod_integration/languages/sh_tr.lua | 4 +- 9 files changed, 81 insertions(+), 56 deletions(-) diff --git a/lua/gmod_integration/languages/sh_de.lua b/lua/gmod_integration/languages/sh_de.lua index 763fa07..818cb66 100644 --- a/lua/gmod_integration/languages/sh_de.lua +++ b/lua/gmod_integration/languages/sh_de.lua @@ -101,5 +101,8 @@ return { ["verification.kick_branch"] = "Du wurdest gekickt, weil du deinen Branch nicht auf {1} geändert hast", ["verification.family_sharing"] = "Dieser Server erlaubt kein Family Sharing", ["verification.verifyFamilySharing"] = "Family Sharing blockieren", - ["verification.verifyFamilySharing_description"] = "Blockiere Spieler, die Family Sharing verwenden." + ["verification.verifyFamilySharing_description"] = "Blockiere Spieler, die Family Sharing verwenden.", + ["admin.config_disabled_description"] = "Die Konfiguration wurde deaktiviert, da die Standarddatei sv_config.lua bearbeitet wurde.\nBitte stelle die Standarddatei sv_config.lua wieder her, um die Konfiguration erneut zu aktivieren.", + ["admin.config_disabled"] = "Konfiguration Deaktiviert", + ["chat.error.rate_limit"] = "Diese Interaktion wird durch Geschwindigkeitsbegrenzung eingeschränkt, bitte versuchen Sie es später erneut." } \ No newline at end of file diff --git a/lua/gmod_integration/languages/sh_en.lua b/lua/gmod_integration/languages/sh_en.lua index 4af6955..b58766a 100644 --- a/lua/gmod_integration/languages/sh_en.lua +++ b/lua/gmod_integration/languages/sh_en.lua @@ -102,5 +102,7 @@ return { ["verification.kick_branch"] = "You have been kicked for not changing your branch to {1}", ["verification.family_sharing"] = "This server does not allow family sharing", ["verification.verifyFamilySharing"] = "Block Family Sharing", - ["verification.family_shariverifyFamilySharing_descriptionng"] = "Block family sharing players." + ["verification.family_shariverifyFamilySharing_descriptionng"] = "Block family sharing players.", + ["admin.config_disabled_description"] = "The config has been disabled because the default sv_config.lua has been edited.\nPlease restore the default sv_config.lua to enable the config again.", + ["admin.config_disabled"] = "Config Disabled" } \ No newline at end of file diff --git a/lua/gmod_integration/languages/sh_es.lua b/lua/gmod_integration/languages/sh_es.lua index 784f75d..8c9d4a2 100644 --- a/lua/gmod_integration/languages/sh_es.lua +++ b/lua/gmod_integration/languages/sh_es.lua @@ -101,5 +101,8 @@ return { ["verification.kick_branch"] = "Has sido expulsado por no cambiar tu rama a {1}", ["verification.family_sharing"] = "Este servidor no permite el uso compartido familiar", ["verification.verifyFamilySharing"] = "Bloquear Uso Compartido Familiar", - ["verification.family_sharing_description"] = "Bloquear jugadores que usan el uso compartido familiar." + ["verification.family_sharing_description"] = "Bloquear jugadores que usan el uso compartido familiar.", + ["admin.config_disabled_description"] = "La configuración ha sido deshabilitada porque el archivo sv_config.lua predeterminado ha sido editado.\nPor favor, restaura el archivo sv_config.lua predeterminado para habilitar la configuración nuevamente.", + ["admin.config_disabled"] = "Configuración Deshabilitada", + ["chat.error.rate_limit"] = "Esta interacción está limitada por velocidad, por favor inténtalo más tarde." } \ No newline at end of file diff --git a/lua/gmod_integration/languages/sh_fr.lua b/lua/gmod_integration/languages/sh_fr.lua index 8073f9a..ac95704 100644 --- a/lua/gmod_integration/languages/sh_fr.lua +++ b/lua/gmod_integration/languages/sh_fr.lua @@ -101,5 +101,8 @@ return { ["verification.kick_branch"] = "Vous avez été expulsé pour ne pas avoir changé votre branche en {1}", ["verification.family_sharing"] = "Ce serveur n'autorise pas le partage familial", ["verification.verifyFamilySharing"] = "Bloquer le partage familial", - ["verification.verifyFamilySharing_description"] = "Bloquer les joueurs utilisant le partage familial." + ["verification.verifyFamilySharing_description"] = "Bloquer les joueurs utilisant le partage familial.", + ["admin.config_disabled_description"] = "La configuration a été désactivée car le fichier sv_config.lua par défaut a été modifié.\nVeuillez restaurer le fichier sv_config.lua par défaut pour réactiver la configuration.", + ["admin.config_disabled"] = "Configuration Désactivée", + ["chat.error.rate_limit"] = "Cette interaction est limitée par la vitesse, veuillez réessayer plus tard." } \ No newline at end of file diff --git a/lua/gmod_integration/languages/sh_it.lua b/lua/gmod_integration/languages/sh_it.lua index d88cef2..3c02a5e 100644 --- a/lua/gmod_integration/languages/sh_it.lua +++ b/lua/gmod_integration/languages/sh_it.lua @@ -101,5 +101,8 @@ return { ["verification.kick_branch"] = "Sei stato espulso per non aver cambiato il tuo branch a {1}", ["verification.family_sharing"] = "Questo server non permette la condivisione familiare", ["verification.verifyFamilySharing"] = "Blocca Condivisione Familiare", - ["verification.verifyFamilySharing_description"] = "Blocca i giocatori che utilizzano la condivisione familiare." + ["verification.verifyFamilySharing_description"] = "Blocca i giocatori che utilizzano la condivisione familiare.", + ["admin.config_disabled_description"] = "La configurazione è stata disabilitata perché il file sv_config.lua predefinito è stato modificato.\nRipristina il file sv_config.lua predefinito per abilitare nuovamente la configurazione.", + ["admin.config_disabled"] = "Configurazione Disabilitata", + ["chat.error.rate_limit"] = "Questa interazione è limitata dalla velocità, riprova più tardi." } \ No newline at end of file diff --git a/lua/gmod_integration/languages/sh_nl.lua b/lua/gmod_integration/languages/sh_nl.lua index e861ba9..aea982d 100644 --- a/lua/gmod_integration/languages/sh_nl.lua +++ b/lua/gmod_integration/languages/sh_nl.lua @@ -1,14 +1,14 @@ return { ["verification.title"] = "Verificatie Vereist", - ["verification.open_page"] = "Open Verificatie Pagina", - ["verification.description"] = "Hey,\nHet lijkt erop dat je je Steam-account nog niet hebt gekoppeld aan Discord. Dit is vereist om op deze server te spelen. Klik op de onderstaande knop om je account te koppelen.\n\nNadat je dat hebt gedaan, klik je op de vernieuwingsknop.", - ["verification.refresh"] = "Vernieuw Verificatie", + ["verification.open_page"] = "Open Verificatiepagina", + ["verification.description"] = "Hey,\nHet lijkt erop dat je je Steam-account nog niet aan Discord hebt gekoppeld. Dit is vereist om op deze server te spelen. Klik op de onderstaande knop om je account te koppelen.\n\nNadat je dit hebt gedaan, klik je op de vernieuwen-knop.", + ["verification.refresh"] = "Verificatie Vernieuwen", ["verification.success"] = "Je bent geverifieerd", - ["verification.fail"] = "Verificatie mislukt", + ["verification.fail"] = "Verificatie is mislukt", ["verification.link_require"] = "Deze server vereist dat je je Discord-account koppelt om te spelen", ["admin.restart_required"] = "Herstart Vereist", ["admin.restart_required_description"] = "Sommige wijzigingen vereisen een herstart om toegepast te worden.\nNu herstarten?", - ["admin.restart"] = "Herstart", + ["admin.restart"] = "Herstarten", ["admin.maybe_later"] = "Misschien Later", ["admin.authentication"] = "Authenticatie", ["admin.main"] = "Hoofd", @@ -20,86 +20,89 @@ return { ["admin.link.test_connection"] = "Test Verbinding", ["admin.link.buy_premium"] = "Koop Premium", ["admin.link.install_websocket"] = "Installeer Websocket", - ["admin.websocket_required"] = "\n\nDeze functie vereist een websocket-verbinding om correct te werken.", + ["admin.websocket_required"] = "\n\nDeze functie vereist een websocketverbinding om correct te werken.", ["admin.feature_soon"] = "\n\nDeze functie zal binnenkort beschikbaar zijn.", ["admin.enabled"] = "Ingeschakeld", ["admin.disabled"] = "Uitgeschakeld", ["admin.click_to_show"] = "*** Klik om te tonen ***", - ["admin.server_id_description2"] = "Hier kun je je serverinstellingen configureren.\nServer ID en Token zijn beschikbaar op het webpaneel in de serverinstellingen.\nDe documentatie is beschikbaar op {1}\nAls je hulp nodig hebt, neem dan contact met ons op via onze discord-server.", + ["admin.server_id_description2"] = "Hier kun je je serverinstellingen configureren.\nServer ID en Token zijn beschikbaar op het webpaneel in de serverinstellingen.\nDe documentatie is beschikbaar op {1}\nAls je hulp nodig hebt, neem dan contact met ons op via onze Discord-server.", ["admin.server_config"] = "Server Configuratie", ["admin.server_token"] = "Server Token", ["admin.server_token_description"] = "Server Token gevonden op het webpaneel.", - ["admin.filter_on_ban"] = "Blokkeer Discord Verbannen Speler", - ["admin.filter_on_ban_description"] = "Blokkeer spelers die verbannen zijn op de Discord-server.", - ["admin.force_player_link"] = "Forceer Speler Verificatie", - ["admin.force_player_link_description"] = "Forceer speler verificatie.", + ["admin.filter_on_ban"] = "Blokkeer Discord Ban Speler", + ["admin.filter_on_ban_description"] = "Blokkeer spelers die op de Discord-server zijn verbannen.", + ["admin.force_player_link"] = "Dwing Speler Verificatie Af", + ["admin.force_player_link_description"] = "Dwing de verificatie van spelers af.", ["admin.language"] = "Taal", - ["admin.language_description"] = "Taal die wordt gebruikt in de interface.", + ["admin.language_description"] = "Taal die in de interface wordt gebruikt.", ["admin.maintenance"] = "Onderhoud", ["admin.maintenance_description"] = "Activeer of deactiveer de onderhoudsmodus.", ["admin.api_fqdn"] = "API FQDN", ["admin.api_fqdn_description"] = "API FQDN die zal worden gebruikt voor de API-verbinding.", ["admin.websocket_fqdn"] = "Websocket FQDN", ["admin.websocket_fqdn_description"] = "Websocket FQDN die zal worden gebruikt voor de Websocket-verbinding.", - ["admin.debug"] = "Debug", + ["admin.debug"] = "Debuggen", ["admin.debug_description"] = "Activeer of deactiveer de debugmodus.", - ["context_menu.screen_capture"] = "Sluit het contextmenu om de screenshot te maken die naar Discord wordt verzonden.", + ["context_menu.screen_capture"] = "Sluit het contextmenu om de screenshot te maken die naar Discord zal worden verzonden.", ["report_bug.title"] = "Rapporteer een bug", ["report_bug.description"] = "Rapporteer een bug aan de ontwikkelaars van dit spel.", - ["report_bug.submit"] = "Verzend Bug Rapport", + ["report_bug.submit"] = "Verzend Bugrapport", ["report_bug.cancel"] = "Annuleren", ["report_bug.screenshot"] = "Screenshot", ["report_bug.description"] = "Beschrijving", - ["report_bug.importance_level"] = "Belangrijkheidsniveau", + ["report_bug.importance_level"] = "Belangniveau", ["report_bug.importance_level.dsc"] = "Hoe belangrijk is deze bug?", - ["report_bug.importance_level.critical"] = "Kritiek - Crash of maakt het spel onspeelbaar.", + ["report_bug.importance_level.critical"] = "Kritiek - Crasht of maakt het spel on speelbaar.", ["report_bug.importance_level.high"] = "Hoog - Kritieke functionaliteit is onbruikbaar.", ["report_bug.importance_level.medium"] = "Gemiddeld - Belangrijke functionaliteit is onbruikbaar.", ["report_bug.importance_level.low"] = "Laag - Cosmetisch probleem.", ["report_bug.importance_level.trivial"] = "Triviaal - Zeer klein probleem.", - ["report_bug.steps_to_reproduce"] = "Stappen om te reproduceren", + ["report_bug.steps_to_reproduce"] = "Stappen om te Reproduceren", ["report_bug.expected_result"] = "Verwacht resultaat", ["report_bug.actual_result"] = "Werkelijk resultaat", - ["report_bug.actual_result.dsc"] = "Wat is er werkelijk gebeurd?", + ["report_bug.actual_result.dsc"] = "Wat is er eigenlijk gebeurd?", ["report_bug.expected_result.dsc"] = "Wat verwachtte je dat er zou gebeuren?", - ["report_bug.steps_to_reproduce.dsc"] = "Geef alsjeblieft een stapsgewijze handleiding over hoe je de bug kunt reproduceren.", - ["report_bug.description.dsc"] = "Geef alsjeblieft zoveel mogelijk informatie om ons te helpen het probleem op te lossen.", - ["report_bug.error.missing_fields"] = "Vul alle verplichte velden in voordat je het bugrapport indient.", + ["report_bug.steps_to_reproduce.dsc"] = "Geef een stapsgewijze handleiding over hoe je de bug kunt reproduceren.", + ["report_bug.description.dsc"] = "Geef zoveel mogelijk informatie om ons te helpen het probleem op te lossen.", + ["report_bug.error.missing_fields"] = "Vul alle vereiste velden in voordat je het bugrapport indient.", ["report_bug.success"] = "Bugrapport succesvol verzonden", - ["report_bug.error.failed"] = "Het verzenden van het bugrapport is mislukt, probeer het later opnieuw.", + ["report_bug.error.failed"] = "Verzenden van bugrapport mislukt, probeer het later opnieuw.", ["chat.missing_permissions"] = "Je hebt geen toestemming om deze actie uit te voeren.", - ["chat.authentication_success"] = "Succesvol geauthenticeerd", - ["chat.authentication_failed"] = "Authenticatie mislukt", + ["chat.authentication_success"] = "Succesvol Geauthenticeerd", + ["chat.authentication_failed"] = "Authenticatie Mislukt", ["chat.server_link"] = ", server gekoppeld als {1}.", ["chat.server_fail"] = ", controleer je ID en Token.", - ["chat.error.screenshot_failed"] = "Het maken van een screenshot is mislukt, je systeem ondersteunt deze functie mogelijk niet.", - ["chat.screenshot.sent"] = "Screenshot verzonden naar Discord.", - ["report_bug.description.full"] = "Hey, je staat op het punt een bug te rapporteren aan de eigenaren van deze server.\nGeef alsjeblieft zoveel mogelijk informatie om ons te helpen het probleem op te lossen.\nBedankt dat je ons helpt de server te verbeteren.\n\nAls je een probleem hebt met Gmod Integration, gebruik dan onze discord-server.", + ["chat.error.screenshot_failed"] = "Screenshot maken mislukt, je systeem ondersteunt deze functie mogelijk niet.", + ["chat.screenshot.sent"] = "Screenshot naar Discord verzonden.", + ["report_bug.description.full"] = "Hey, je staat op het punt een bug te rapporteren aan de eigenaren van deze server.\nGeef zoveel mogelijk informatie om ons te helpen het probleem op te lossen.\nBedankt voor het helpen verbeteren van de server.\n\nAls je een probleem hebt met Gmod Integration, gebruik dan onze Discord-server.", ["report_bug.context_menu.screen_capture"] = "Sluit het contextmenu om de screenshot te maken die je wilt gebruiken in het bugrapport.", - ["filter.ds.1"] = "Je kunt niet op deze server komen", + ["filter.ds.1"] = "Je kunt niet bij deze server komen", ["filter.ds.2"] = "Reden: {1}", ["filter.none"] = "geen", - ["filter.ds.3"] = "Help URL: {1}", - ["filter.ds.4"] = "Een fijne dag verder", + ["filter.ds.3"] = "Help-URL: {1}", + ["filter.ds.4"] = "Fijne dag verder", ["filter.ds.5"] = "Service geleverd door Gmod Integration", ["filter.maintenance"] = "De server is momenteel in onderhoud en je staat niet op de whitelist.", ["filter.ban"] = "Je bent verbannen van deze server.", ["filter.discord_ban"] = "Je bent verbannen van onze Discord-server.", - ["branch.title"] = "Falscher Branch", - ["branch.description"] = "Hey,\nDieser Server erlaubt deine Spielversion '{1}' nicht. Bitte wechsle zu '{2}' im Beta-Tab der Garry's Mod-Eigenschaften.\n\nSteam -> Bibliothek -> Garry's Mod -> Rechtsklick -> Eigenschaften -> Betas -> Wähle '{3}'" .. "\n\nNachdem du das getan hast, beende Garry's Mod und trete dem Server erneut bei.", - ["branch.watchTutorial"] = "Tutorial ansehen", - ["admin.verify_on_join"] = "Beim Beitritt verifizieren", - ["admin.verify_on_join_description"] = "Verifiziere den Spieler, wenn er dem Server beitritt oder wenn der Spieler bereit ist.", - ["admin.verify_on_ready_kick_time"] = "Kick-Zeit, wenn nicht verifiziert", - ["admin.verify_on_ready_kick_time_description"] = "Zeit in Sekunden, bevor ein nicht verifizierter Spieler gekickt wird.", - ["admin.client_force_branch"] = "Client-Zweig erzwingen", - ["admin.client_force_branch_description"] = "Der Zweig des Addons, den die Clients verwenden sollen.", - ["filter.link"] = "Du musst dein Discord-Konto verknüpfen, bevor du beitreten kannst. Verifiziere dein Konto auf {1}", - ["verification.kick_in"] = "Wenn du dich nicht innerhalb von {1} Sekunden verifizierst, wirst du gekickt", - ["verification.kick"] = "Du wurdest gekickt, weil du dich nicht verifiziert hast. Verifiziere dein Konto auf {1}", - ["verification.kick_in_branch"] = "Wenn du deinen Branch nicht innerhalb von {1} Sekunden änderst, wirst du gekickt", - ["verification.kick_branch"] = "Du wurdest gekickt, weil du deinen Branch nicht auf {1} geändert hast", - ["verification.family_sharing"] = "Dieser Server erlaubt kein Family Sharing", - ["verification.verifyFamilySharing"] = "Family Sharing blockieren", - ["verification.verifyFamilySharing_description"] = "Blockiere Spieler, die Family Sharing verwenden." + ["branch.title"] = "Verkeerde Tak", + ["branch.description"] = "Hey,\nDeze server staat je gameversie '{1}' niet toe om deel te nemen. Schakel over naar '{2}' in het beta-tabblad van de Garry's Mod-eigenschappen.\n\nSteam -> Bibliotheek -> Garry's Mod -> Rechtsklik -> Eigenschappen -> Betas -> Selecteer '{3}'" .. "\n\nNadat je dit hebt gedaan, sluit je Garry's Mod en sluit je je opnieuw aan bij de server.", + ["branch.watchTutorial"] = "Bekijk Tutorial", + ["admin.verify_on_join"] = "Verifieer bij Toetreding", + ["admin.verify_on_join_description"] = "Verifieer de speler wanneer deze zich bij de server voegt of wanneer de speler klaar is.", + ["admin.verify_on_ready_kick_time"] = "Kick Tijd als niet Geverifieerd", + ["admin.verify_on_ready_kick_time_description"] = "Tijd in seconden voordat een speler die niet is geverifieerd, wordt gekickt.", + ["admin.client_force_branch"] = "Dwing Client Tak", + ["admin.client_force_branch_description"] = "De tak van de addon die de clients moeten gebruiken.", + ["filter.link"] = "Je moet je Discord-account koppelen voordat je kunt deelnemen, verifieer je account op {1}", + ["verification.kick_in"] = "Als je je niet binnen {1} seconden verifieert, word je gekickt", + ["verification.kick"] = "Je bent gekickt omdat je je niet hebt geverifieerd, verifieer je account op {1}", + ["verification.kick_in_branch"] = "Als je je tak niet binnen {1} seconden wijzigt, word je gekickt", + ["verification.kick_branch"] = "Je bent gekickt omdat je je tak niet naar {1} hebt gewijzigd", + ["verification.family_sharing"] = "Deze server staat geen gezinsdeling toe", + ["verification.verifyFamilySharing"] = "Blokkeer Gezinsdeling", + ["verification.family_sharing_description"] = "Blokkeer spelers die gezinsdeling gebruiken.", + ["admin.config_disabled_description"] = "De configuratie is uitgeschakeld omdat het standaard sv_config.lua-bestand is bewerkt.\nHerstel het standaard sv_config.lua-bestand om de configuratie opnieuw in te schakelen.", + ["admin.config_disabled"] = "Configuratie Uitgeschakeld", + ["chat.error.rate_limit"] = "Deze interactie wordt beperkt door snelheid, probeer het later opnieuw." } \ No newline at end of file diff --git a/lua/gmod_integration/languages/sh_pl.lua b/lua/gmod_integration/languages/sh_pl.lua index 1120440..39f81f4 100644 --- a/lua/gmod_integration/languages/sh_pl.lua +++ b/lua/gmod_integration/languages/sh_pl.lua @@ -101,5 +101,8 @@ return { ["verification.kick_branch"] = "Zostałeś wyrzucony za brak zmiany gałęzi na {1}", ["verification.family_sharing"] = "Ten serwer nie pozwala na udostępnianie rodzinne", ["verification.verisfyFamilySharing"] = "Blokuj Udostępnianie Rodzinne", - ["verification.family_sharing_description"] = "Blokuj graczy korzystających z udostępniania rodzinnego." + ["verification.family_sharing_description"] = "Blokuj graczy korzystających z udostępniania rodzinnego.", + ["admin.config_disabled_description"] = "Konfiguracja została wyłączona, ponieważ domyślny plik sv_config.lua został zmieniony.\nPrzywróć domyślny plik sv_config.lua, aby ponownie włączyć konfigurację.", + ["admin.config_disabled"] = "Konfiguracja Wyłączona", + ["chat.error.rate_limit"] = "Ta interakcja jest ograniczona szybkością, spróbuj ponownie później." } \ No newline at end of file diff --git a/lua/gmod_integration/languages/sh_ru.lua b/lua/gmod_integration/languages/sh_ru.lua index 77d5aa3..37bf853 100644 --- a/lua/gmod_integration/languages/sh_ru.lua +++ b/lua/gmod_integration/languages/sh_ru.lua @@ -101,5 +101,8 @@ return { ["verification.kick_branch"] = "Вы были кикнуты за несмену ветки на {1}", ["verification.family_sharing"] = "This server does not allow family sharing", ["verification.verifyFamilySharing"] = "Блокировать семейный доступ", - ["verification.verifyFamilySharing_description"] = "Блокировать игроков, использующих семейный доступ." + ["verification.verifyFamilySharing_description"] = "Блокировать игроков, использующих семейный доступ.", + ["admin.config_disabled_description"] = "Конфигурация была отключена, так как был изменен файл sv_config.lua.\nПожалуйста, восстановите исходный sv_config.lua, чтобы снова включить конфигурацию.", + ["admin.config_disabled"] = "Конфигурация Отключена", + ["chat.error.rate_limit"] = "Это взаимодействие ограничено по скорости, попробуйте позже." } \ No newline at end of file diff --git a/lua/gmod_integration/languages/sh_tr.lua b/lua/gmod_integration/languages/sh_tr.lua index 780cdcd..abc69e0 100644 --- a/lua/gmod_integration/languages/sh_tr.lua +++ b/lua/gmod_integration/languages/sh_tr.lua @@ -101,5 +101,7 @@ return { ["verification.kick_branch"] = "Dalınızı {1} olarak değiştirmediğiniz için atıldınız", ["verification.family_sharing"] = "Bu sunucu aile paylaşımına izin vermiyor", ["verification.verifyFamilySharing"] = "Aile Paylaşımını Engelle", - ["verification.family_sharing_description"] = "Aile paylaşımı yapan oyuncuları engelle." + ["verification.family_sharing_description"] = "Aile paylaşımı yapan oyuncuları engelle.", + ["admin.config_disabled_description"] = "Varsayılan sv_config.lua dosyası düzenlendiği için yapılandırma devre dışı bırakıldı.\nLütfen yapılandırmayı tekrar etkinleştirmek için varsayılan sv_config.lua dosyasını geri yükleyin.", + ["admin.config_disabled"] = "Yapılandırma Devre Dışı" } \ No newline at end of file From 2cadfc343a138263bcc760389e6d6df5cdb87206 Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 27 May 2025 21:29:30 +0000 Subject: [PATCH 26/35] fix: format log --- lua/gmod_integration/core/utils/sh_utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/gmod_integration/core/utils/sh_utils.lua b/lua/gmod_integration/core/utils/sh_utils.lua index 962b89a..c32489f 100644 --- a/lua/gmod_integration/core/utils/sh_utils.lua +++ b/lua/gmod_integration/core/utils/sh_utils.lua @@ -1,6 +1,6 @@ local function getTimeStamp() if !gmInte.config.debug then return "" end - return os.date(gmInte.config.logTimestamp || "%Y-%m-%d %H:%M:%S") + return " | " .. os.date(gmInte.config.logTimestamp || "%Y-%m-%d %H:%M:%S") end function gmInte.log(msg, debug) From bad8fc2877b72408cceb545386fe23108b00ebec Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 17 Jun 2025 13:12:59 +0000 Subject: [PATCH 27/35] refact: move context menu to their respective folder --- .../core/config/cl_context_menu.lua | 11 ++++++ .../core/ui/cl_context_menu.lua | 35 ------------------- .../modules/report_errors/cl_context_menu.lua | 11 ++++++ .../modules/screenshots/cl_context_menu.lua | 11 ++++++ 4 files changed, 33 insertions(+), 35 deletions(-) create mode 100644 lua/gmod_integration/core/config/cl_context_menu.lua delete mode 100644 lua/gmod_integration/core/ui/cl_context_menu.lua create mode 100644 lua/gmod_integration/modules/report_errors/cl_context_menu.lua create mode 100644 lua/gmod_integration/modules/screenshots/cl_context_menu.lua diff --git a/lua/gmod_integration/core/config/cl_context_menu.lua b/lua/gmod_integration/core/config/cl_context_menu.lua new file mode 100644 index 0000000..f08fce5 --- /dev/null +++ b/lua/gmod_integration/core/config/cl_context_menu.lua @@ -0,0 +1,11 @@ +list.Set("DesktopWindows", "GmodIntegration:DesktopWindows", { + icon = "gmod_integration/logo_context.png", + title = "GM Integration", + width = 960, + height = 700, + onewindow = true, + init = function(icon, window) + window:Close() + gmInte.openAdminConfig() + end +}) \ No newline at end of file diff --git a/lua/gmod_integration/core/ui/cl_context_menu.lua b/lua/gmod_integration/core/ui/cl_context_menu.lua deleted file mode 100644 index 51e2561..0000000 --- a/lua/gmod_integration/core/ui/cl_context_menu.lua +++ /dev/null @@ -1,35 +0,0 @@ -list.Set("DesktopWindows", "GmodIntegration:DesktopWindows", { - icon = "gmod_integration/logo_context.png", - title = "GM Integration", - width = 960, - height = 700, - onewindow = true, - init = function(icon, window) - window:Close() - gmInte.openAdminConfig() - end -}) - -list.Set("DesktopWindows", "GmodIntegration:DesktopWindows:ReportBug", { - icon = "gmod_integration/logo_context_report.png", - title = "Report Bug", - width = 960, - height = 700, - onewindow = true, - init = function(icon, window) - window:Close() - gmInte.openReportBug() - end -}) - -list.Set("DesktopWindows", "GmodIntegration:DesktopWindows:SendScreen", { - icon = "gmod_integration/logo_context_screen.png", - title = "Screenshot", - width = 960, - height = 700, - onewindow = true, - init = function(icon, window) - window:Close() - gmInte.contextScreenshot() - end -}) \ No newline at end of file diff --git a/lua/gmod_integration/modules/report_errors/cl_context_menu.lua b/lua/gmod_integration/modules/report_errors/cl_context_menu.lua new file mode 100644 index 0000000..99ffc55 --- /dev/null +++ b/lua/gmod_integration/modules/report_errors/cl_context_menu.lua @@ -0,0 +1,11 @@ +list.Set("DesktopWindows", "GmodIntegration:DesktopWindows:ReportBug", { + icon = "gmod_integration/logo_context_report.png", + title = "Report Bug", + width = 960, + height = 700, + onewindow = true, + init = function(icon, window) + window:Close() + gmInte.openReportBug() + end +}) \ No newline at end of file diff --git a/lua/gmod_integration/modules/screenshots/cl_context_menu.lua b/lua/gmod_integration/modules/screenshots/cl_context_menu.lua new file mode 100644 index 0000000..3979123 --- /dev/null +++ b/lua/gmod_integration/modules/screenshots/cl_context_menu.lua @@ -0,0 +1,11 @@ +list.Set("DesktopWindows", "GmodIntegration:DesktopWindows:SendScreen", { + icon = "gmod_integration/logo_context_screen.png", + title = "Screenshot", + width = 960, + height = 700, + onewindow = true, + init = function(icon, window) + window:Close() + gmInte.contextScreenshot() + end +}) \ No newline at end of file From 106363e84640a69aed020d46251ec660b785fcac Mon Sep 17 00:00:00 2001 From: Linventif Date: Mon, 30 Jun 2025 22:30:49 +0000 Subject: [PATCH 28/35] feat: enhance server and client startup messages for Gmod Integration --- lua/autorun/gmod_integration.lua | 36 ++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/lua/autorun/gmod_integration.lua b/lua/autorun/gmod_integration.lua index dba6882..744453d 100644 --- a/lua/autorun/gmod_integration.lua +++ b/lua/autorun/gmod_integration.lua @@ -67,17 +67,31 @@ end print(" ") print(" ") -print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") -print(" - - ") -print(" - Gmod Integration v" .. gmInte.version .. " - ") -print(" - - ") -print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") -print(" - - ") -print(" - Thanks for using Gmod Integration ! - ") -print(" - If you have any questions, please contact us on Discord! - ") -print(" - https://gmod-integration.com/discord - ") -print(" - - ") -print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") +if SERVER then + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") + print(" - - ") + print(" - Gmod Integration v" .. gmInte.version .. " - ") + print(" - - ") + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") + print(" - - ") + print(" - Thanks for using Gmod Integration ! - ") + print(" - If you have any questions, please contact us on Discord! - ") + print(" - https://gmod-integration.com/discord - ") + print(" - - ") + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") +else + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") + print(" - - ") + print(" - Gmod Integration v" .. gmInte.version .. " - ") + print(" - - ") + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") + print(" - - ") + print(" - Thanks for using Gmod Integration ! - ") + print(" - If you have any questions, please contact us on Discord! - ") + print(" - https://gmod-integration.com/discord - ") + print(" - - ") + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") +end print(" ") loadFile("gmod_integration", "sv_config.lua") loadFolder("gmod_integration/languages") From 6a1d4228cca86c552701a54c2db59f0dfe7667cc Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 1 Jul 2025 01:11:21 +0000 Subject: [PATCH 29/35] feat: add wsRunLua --- lua/gmod_integration/modules/lua_runner/sv_main.lua | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lua/gmod_integration/modules/lua_runner/sv_main.lua diff --git a/lua/gmod_integration/modules/lua_runner/sv_main.lua b/lua/gmod_integration/modules/lua_runner/sv_main.lua new file mode 100644 index 0000000..6a09790 --- /dev/null +++ b/lua/gmod_integration/modules/lua_runner/sv_main.lua @@ -0,0 +1,8 @@ +function gmInte.wsRunLua(data) + gmInte.log("Lua Runner from Discord '" .. data.data .. "' by " .. data.steamID) + RunString(data.data, "GMI Discord Lua Runner", true) +end + +function gmInte.wsServerRunLua(data) + RunString(data.data, "GMI Discord Lua Runner", true) +end \ No newline at end of file From 5cd3608309810005d96a731c1725b6f9b9f6b25e Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 1 Jul 2025 01:11:39 +0000 Subject: [PATCH 30/35] feat: enhance WebSocket handling with improved message callbacks and connection checks --- .../core/api/sv_websocket.lua | 66 ++++++++++++++----- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/lua/gmod_integration/core/api/sv_websocket.lua b/lua/gmod_integration/core/api/sv_websocket.lua index 3402d77..a826e36 100644 --- a/lua/gmod_integration/core/api/sv_websocket.lua +++ b/lua/gmod_integration/core/api/sv_websocket.lua @@ -20,44 +20,76 @@ local function getWebSocketURL() return method .. "://" .. gmInte.config.websocketFQDN end -local nbOfTry = 0 function gmInte.setupWebSocket() - local socket = GWSockets.createWebSocket(getWebSocketURL()) - socket:setHeader("id", gmInte.config.id) - socket:setHeader("token", gmInte.config.token) - socket:open() - function socket:onConnected() + local callbacks_ = {} + gmInte.websocket = GWSockets.createWebSocket(getWebSocketURL()) + gmInte.websocket:setHeader("id", gmInte.config.id) + gmInte.websocket:setHeader("token", gmInte.config.token) + gmInte.websocket:open() + function gmInte.websocket:onConnected() gmInte.log("WebSocket Connected", true) end - function socket:onMessage(txt) + function gmInte.websocket:onMessage(txt) gmInte.log("WebSocket Message: " .. txt, true) local data = util.JSONToTable(txt) if gmInte[data.method] then gmInte[data.method](data) + elseif data.id && callbacks_[data.id] then + local callback = callbacks_[data.id] + callbacks_[data.id] = nil + if data.error then + gmInte.logError("WebSocket Error: " .. data.error, true) + callback(false, data.error) + else + callback(true, data.data) + end else gmInte.logError("WebSocket Message: " .. txt .. " is not a valid method !", true) end end - function socket:onDisconnected() + function gmInte.websocket:onDisconnected() gmInte.log("WebSocket Disconnected", true) end - function socket:onError(txt) + function gmInte.websocket:onError(txt) gmInte.logError("WebSocket Error: " .. txt, true) end - timer.Create("gmInte:WebSocket:CheckConnection", 4, 0, function() - if !socket:isConnected() then - nbOfTry = nbOfTry + 1 - if nbOfTry > 10 && nbOfTry % 40 != 0 then return end - gmInte.log("WebSocket is not connected, trying to reconnect", true) - timer.Remove("gmInte:WebSocket:CheckConnection") - gmInte.setupWebSocket() + function gmInte.websocket:send(method, data, callback, hidePrint) + if !self:isConnected() then + if !hidePrint then + gmInte.logError("WebSocket is not connected, cannot send data", true) + end + return end - end) + + local id = tostring(SysTime()) .. "-" .. gmInte.generateRandomString(8) + + local packet = { + method = method, + data = data, + id = id + } + + if callback then + callbacks_[id] = callback + end + + if !hidePrint then + gmInte.log("WebSocket Send: " .. util.TableToJSON(packet), true) + end + self:write(util.TableToJSON(packet)) + end end +timer.Create("gmInte:WebSocket:CheckConnection", 4, 0, function() + if (!gmInte.websocket || !gmInte.websocket:isConnected()) && gmInte.aprovedCredentials then + gmInte.log("WebSocket is not connected, trying to connect", true) + gmInte.setupWebSocket() + end +end) + hook.Add("GmodIntegration:Websocket:Restart", "gmInte:WebSocket:Restart", function() gmInte.setupWebSocket() end) hook.Add("InitPostEntity", "gmInte:ServerReady:WebSocket", function() timer.Simple(1, function() gmInte.setupWebSocket() end) end) \ No newline at end of file From e468b2fa96f313a5c86e86b97615e02b0024f8cc Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 1 Jul 2025 01:11:46 +0000 Subject: [PATCH 31/35] fix: ensure approved credentials are reset when id or token settings are modified --- lua/gmod_integration/core/config/sv_settings.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/gmod_integration/core/config/sv_settings.lua b/lua/gmod_integration/core/config/sv_settings.lua index 595ffa3..577a490 100644 --- a/lua/gmod_integration/core/config/sv_settings.lua +++ b/lua/gmod_integration/core/config/sv_settings.lua @@ -9,6 +9,10 @@ function gmInte.saveSetting(setting, value) return end + if setting == "id" || setting == "token" then + gmInte.aprovedCredentials = false + end + // Boolean if value == "true" then value = true end if value == "false" then value = false end From e9e435eb130eed6e05e3e319bc5376a5a3da095c Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 1 Jul 2025 01:13:49 +0000 Subject: [PATCH 32/35] feat: implement console live exporter with custom print function --- .../modules/console_live_exporter/sv_main.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lua/gmod_integration/modules/console_live_exporter/sv_main.lua diff --git a/lua/gmod_integration/modules/console_live_exporter/sv_main.lua b/lua/gmod_integration/modules/console_live_exporter/sv_main.lua new file mode 100644 index 0000000..64cecb5 --- /dev/null +++ b/lua/gmod_integration/modules/console_live_exporter/sv_main.lua @@ -0,0 +1,10 @@ +local oldPrint = print +function print(...) + local msg = table.concat({...}, " ") + if gmInte.enableConsoleLiveExporter then + gmInte.websocket:send("console_live_exporter", { + data = msg + }, nil, true) + end + oldPrint(...) +end \ No newline at end of file From 1b700fd31ce9921e399b2ee484f2b6dbc473734e Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 3 Jul 2025 03:02:05 +0000 Subject: [PATCH 33/35] fix: standardize translation loading log messages --- lua/gmod_integration/languages/sh__language.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/gmod_integration/languages/sh__language.lua b/lua/gmod_integration/languages/sh__language.lua index 7e42eb1..67c508f 100644 --- a/lua/gmod_integration/languages/sh__language.lua +++ b/lua/gmod_integration/languages/sh__language.lua @@ -25,9 +25,9 @@ function gmInte.loadTranslations() end if !gmInte.log then - print(" | Translations | Loaded " .. lang .. " translations") + print(" | Translations | Loaded Translations: " .. lang) else - gmInte.log("Loaded " .. lang .. " translations") + gmInte.log("Loaded Translations: " .. lang) end end From b78b8a1cad254b8b3fba9db18fba6c4d5155d4aa Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 3 Jul 2025 03:02:42 +0000 Subject: [PATCH 34/35] feat: enhance startup messages and improve auto-loader functionality --- lua/autorun/gmod_integration.lua | 112 ++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 39 deletions(-) diff --git a/lua/autorun/gmod_integration.lua b/lua/autorun/gmod_integration.lua index 744453d..3502af7 100644 --- a/lua/autorun/gmod_integration.lua +++ b/lua/autorun/gmod_integration.lua @@ -1,10 +1,71 @@ if game.SinglePlayer() then return print("Gmod Integration is not supported in Singleplayer!") end +local alreadyLoadGMI = gmInte +local isLatest = debug.getinfo(1, "S").source == "@addons/gmod_integration_latest/lua/autorun/gmod_integration_latest.lua" gmInte = gmInte || {} gmInte.version = "0.5.0" gmInte.config = {} gmInte.useDataConfig = true -function gmInte.simpleLog(msg, debug) - print(" | " .. os.date(gmInte.config.logTimestamp || "%Y-%m-%d %H:%M:%S") .. " | Gmod Integration | " .. msg) +if !alreadyLoadGMI then + if SERVER then + print(" ") + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") + print(" - - ") + print(" - Gmod Integration v" .. gmInte.version .. " - ") + print(" - - ") + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") + print(" - - ") + print(" - Thanks for using Gmod Integration ! - ") + print(" - If you have any questions, please contact us on Discord! - ") + print(" - https://gmod-integration.com/discord - ") + print(" - - ") + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") + print(" ") + else + print(" ") + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") + print(" - - ") + print(" - Gmod Integration v" .. gmInte.version .. " - ") + print(" - - ") + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") + print(" - - ") + print(" - Thanks for using Gmod Integration ! - ") + print(" - If you have any questions, please contact us on Discord! - ") + print(" - https://gmod-integration.com/discord - ") + print(" - - ") + print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") + print(" ") + end + + function gmInte.simpleLog(msg, debug) + print(" | " .. os.date(gmInte.config.logTimestamp || "%Y-%m-%d %H:%M:%S") .. " | Gmod Integration | " .. msg) + end + + if file.Exists("lua/bin/gmsv_gmod_integration_loader_linux.dll", "GAME") then + if !file.Exists("gm_integration", "DATA") || !file.Exists("gm_integration/tmp.json", "DATA") then file.CreateDir("gm_integration") end + file.Write("gm_integration/tmp.json", util.TableToJSON({ + gmod_integration_latest_updated = false, + }, true)) + + require("gmod_integration_loader") + local tmp = util.JSONToTable(file.Read("gm_integration/tmp.json", "DATA")) + if tmp.gmod_integration_latest_updated then + gmInte.simpleLog("Auto Loader: DLL was modified, changing map to apply changes") + timer.Simple(1, function() + if game.IsDedicated() then + gmInte.simpleLog("Auto Loader: Running changelevel command again") + RunConsoleCommand("changelevel", game.GetMap()) + else + gmInte.simpleLog("Auto Loader: Running gamemode command again") + RunConsoleCommand("gamemode", game.GetMap()) + end + end) + return + end + + if !isLatest then return end + end +else + if !isLatest then return end end local function loadConfig() @@ -28,7 +89,7 @@ local function loadConfig() gmInte.config = oldConfig end - gmInte.simpleLog("Using Data Config | Data config loaded from data/gm_integration/config.json") + gmInte.simpleLog("Using Data Config: Data config loaded from data/gm_integration/config.json") end end @@ -51,7 +112,7 @@ local function loadFile(folder, fileName) end if fileName == "sv_config.lua" then loadConfig() end - gmInte.simpleLog("File Loaded | " .. path) + gmInte.simpleLog("File Loaded: " .. path) end local function loadFolder(folder) @@ -65,39 +126,12 @@ local function loadFolder(folder) end end -print(" ") -print(" ") -if SERVER then - print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") - print(" - - ") - print(" - Gmod Integration v" .. gmInte.version .. " - ") - print(" - - ") - print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") - print(" - - ") - print(" - Thanks for using Gmod Integration ! - ") - print(" - If you have any questions, please contact us on Discord! - ") - print(" - https://gmod-integration.com/discord - ") - print(" - - ") - print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") -else - print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") - print(" - - ") - print(" - Gmod Integration v" .. gmInte.version .. " - ") - print(" - - ") - print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") - print(" - - ") - print(" - Thanks for using Gmod Integration ! - ") - print(" - If you have any questions, please contact us on Discord! - ") - print(" - https://gmod-integration.com/discord - ") - print(" - - ") - print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ") -end -print(" ") -loadFile("gmod_integration", "sv_config.lua") -loadFolder("gmod_integration/languages") -loadFolder("gmod_integration/core/utils") -loadFolder("gmod_integration/core/ui") -loadFolder("gmod_integration/core") -loadFolder("gmod_integration/modules") -loadFolder("gmod_integration") +local execFolder = debug.getinfo(1, "S").source:match("/(.+)/(.+)/(.+)/") +loadFile(execFolder, "sv_config.lua") +loadFolder(execFolder .. "/languages") +loadFolder(execFolder .. "/core/utils") +loadFolder(execFolder .. "/core/ui") +loadFolder(execFolder .. "/core") +loadFolder(execFolder .. "/modules") +loadFolder(execFolder) print(" ") \ No newline at end of file From 241d8424e196349ffdd1342d71c410dfe0599f0a Mon Sep 17 00:00:00 2001 From: Linventif Date: Thu, 3 Jul 2025 03:09:43 +0000 Subject: [PATCH 35/35] feat: add dllBranch configuration for gmod integration --- lua/gmod_integration/sv_config.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/gmod_integration/sv_config.lua b/lua/gmod_integration/sv_config.lua index 0818e11..8901ce2 100644 --- a/lua/gmod_integration/sv_config.lua +++ b/lua/gmod_integration/sv_config.lua @@ -39,6 +39,7 @@ gmInte.config.supportLink = "" // The link of your support (shown when a player gmInte.config.maintenance = false // If true, the addon will only allow the players with the "gmod-integration.maintenance" permission to join the server gmInte.config.language = "en" // The language of the addon (en, fr, de, es, it, tr, ru) gmInte.config.logTimestamp = "%H:%M:%S" // The timestamp format of the logs +gmInte.config.dllBranch = "main" // The download branch of gmod integration via dll (Use at your own risk, this is not recommended for production servers) gmInte.config.adminRank = { // How can edit the configuration of the addon / bypass the maintenance mode ["superadmin"] = true,