From c18c71f14f223e2fc0a92565da2714d5278f392e Mon Sep 17 00:00:00 2001 From: "sebajura1234@gmail.com" Date: Fri, 19 May 2023 21:25:58 +0200 Subject: [PATCH] fix --- Client/mods/deathmatch/logic/CRegisteredCommands.cpp | 3 +++ Server/mods/deathmatch/logic/CMainConfig.cpp | 7 ++++++- Server/mods/deathmatch/logic/CMainConfig.h | 1 + Server/mods/deathmatch/logic/CRegisteredCommands.cpp | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CRegisteredCommands.cpp b/Client/mods/deathmatch/logic/CRegisteredCommands.cpp index 4faa169071..31fd34e8db 100644 --- a/Client/mods/deathmatch/logic/CRegisteredCommands.cpp +++ b/Client/mods/deathmatch/logic/CRegisteredCommands.cpp @@ -27,6 +27,9 @@ bool CRegisteredCommands::AddCommand(CLuaMain* pLuaMain, const char* szKey, cons assert(pLuaMain); assert(szKey); + if (g_pCore->GetCommands()->Get(szKey)) + return false; + // Check if we already have this key and handler SCommand* pCommand = GetCommand(szKey, pLuaMain); if (pCommand) diff --git a/Server/mods/deathmatch/logic/CMainConfig.cpp b/Server/mods/deathmatch/logic/CMainConfig.cpp index be32e6c9eb..a1b3bf02b2 100644 --- a/Server/mods/deathmatch/logic/CMainConfig.cpp +++ b/Server/mods/deathmatch/logic/CMainConfig.cpp @@ -660,6 +660,8 @@ bool CMainConfig::LoadExtended() } } while (pNode); + RegisterCommands(); + // Handle the nodes pNode = NULL; uiCurrentIndex = 0; @@ -749,7 +751,11 @@ bool CMainConfig::LoadExtended() CLogger::ProgressDotsEnd(); CLogger::SetMinLogLevel(LOGLEVEL_LOW); + return true; +} +void CMainConfig::RegisterCommands() +{ // Register the commands RegisterCommand("start", CConsoleCommands::StartResource, false, "Usage: start \nStart a loaded resource eg: start admin"); RegisterCommand("stop", CConsoleCommands::StopResource, false, "Usage: stop \nStop a resource eg: stop admin"); @@ -819,7 +825,6 @@ bool CMainConfig::LoadExtended() RegisterCommand("sfakelag", CConsoleCommands::FakeLag, false, "Usage: sfakelag []\nOnly available if enabled in the mtaserver.conf file.\nAdds " "artificial packet loss, ping, jitter and bandwidth limits to the server-client connections."); - return true; } bool CMainConfig::Save() diff --git a/Server/mods/deathmatch/logic/CMainConfig.h b/Server/mods/deathmatch/logic/CMainConfig.h index b5f658a88a..85b66efd58 100644 --- a/Server/mods/deathmatch/logic/CMainConfig.h +++ b/Server/mods/deathmatch/logic/CMainConfig.h @@ -47,6 +47,7 @@ class CMainConfig : public CXMLConfig bool Load(); bool LoadExtended(); + void RegisterCommands(); bool Save(); const std::string& GetServerName() { return m_strServerName; }; diff --git a/Server/mods/deathmatch/logic/CRegisteredCommands.cpp b/Server/mods/deathmatch/logic/CRegisteredCommands.cpp index 57432756e0..d7d1937f16 100644 --- a/Server/mods/deathmatch/logic/CRegisteredCommands.cpp +++ b/Server/mods/deathmatch/logic/CRegisteredCommands.cpp @@ -18,6 +18,7 @@ #include "CClient.h" #include "CConsoleClient.h" #include "CPlayer.h" +#include "CGame.h" CRegisteredCommands::CRegisteredCommands(CAccessControlListManager* pACLManager) { @@ -35,6 +36,9 @@ bool CRegisteredCommands::AddCommand(CLuaMain* pLuaMain, const char* szKey, cons assert(pLuaMain); assert(szKey); + if (g_pGame->GetConsole()->GetCommand(szKey)) + return false; + // Check if we already have this key and handler SCommand* pCommand = GetCommand(szKey, pLuaMain);