From 0d2eaecd7687e013a88a4727dd588aab27fa7f94 Mon Sep 17 00:00:00 2001 From: Davis22d Date: Sun, 29 Jun 2025 19:32:45 +0200 Subject: [PATCH] onAccountNameChange event Fixes #4246 --- Server/mods/deathmatch/logic/CGame.cpp | 2 +- .../mods/deathmatch/logic/CStaticFunctionDefinitions.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Server/mods/deathmatch/logic/CGame.cpp b/Server/mods/deathmatch/logic/CGame.cpp index 16e7b7312b..9f0de608a3 100644 --- a/Server/mods/deathmatch/logic/CGame.cpp +++ b/Server/mods/deathmatch/logic/CGame.cpp @@ -1697,7 +1697,7 @@ void CGame::AddBuiltInEvents() // Account events m_Events.AddEvent("onAccountDataChange", "account, key, value", NULL, false); - + m_Events.AddEvent("onAccountNameChange", "account, previousName, newName", nullptr, false); m_Events.AddEvent("onAccountCreate", "account", NULL, false); m_Events.AddEvent("onAccountRemove", "account", NULL, false); diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index f8bfad986a..9cba7900bd 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -11674,7 +11674,15 @@ bool CStaticFunctionDefinitions::SetAccountName(CAccount* pAccount, SString strN } else { + CLuaArguments arguments; + arguments.PushAccount(pAccount); + arguments.PushString(pAccount->GetName().c_str()); + arguments.PushString(strNewName); + if (!m_pMapManager->GetRootElement()->CallEvent("onAccountNameChange", arguments)) + return false; + pAccount->SetName(strNewName); + return true; } }