mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 17:19:07 +00:00
feat(Scripts/Commands): Implement character changeaccount command (#13532)
* feat(Scripts/Commands): Implement character changeaccount command * strings and stuff * clear unused
This commit is contained in:
@@ -72,6 +72,7 @@ public:
|
||||
{ "customize", HandleCharacterCustomizeCommand, SEC_GAMEMASTER, Console::Yes },
|
||||
{ "changefaction", HandleCharacterChangeFactionCommand, SEC_GAMEMASTER, Console::Yes },
|
||||
{ "changerace", HandleCharacterChangeRaceCommand, SEC_GAMEMASTER, Console::Yes },
|
||||
{ "changeaccount", HandleCharacterChangeAccountCommand, SEC_ADMINISTRATOR, Console::Yes },
|
||||
{ "check", characterCheckCommandTable },
|
||||
{ "erase", HandleCharacterEraseCommand, SEC_CONSOLE, Console::Yes },
|
||||
{ "deleted", characterDeletedCommandTable },
|
||||
@@ -1061,6 +1062,55 @@ public:
|
||||
handler->PSendSysMessage("--------------------------------------");
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleCharacterChangeAccountCommand(ChatHandler* handler, std::string accountName, Optional<PlayerIdentifier> player)
|
||||
{
|
||||
if (!player)
|
||||
{
|
||||
player = PlayerIdentifier::FromTargetOrSelf(handler);
|
||||
}
|
||||
|
||||
if (!player)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uint32 accountId = AccountMgr::GetId(accountName))
|
||||
{
|
||||
if (AccountMgr::GetCharactersCount(accountId) >= 10)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, accountName, accountId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CharacterCacheEntry const* cache = sCharacterCache->GetCharacterCacheByName(player->GetName()))
|
||||
{
|
||||
std::string accName;
|
||||
AccountMgr::GetName(cache->AccountId, accName);
|
||||
handler->PSendSysMessage(LANG_CMD_CHAR_CHANGE_ACC_SUCCESS, player->GetName(), player->GetGUID().GetCounter(), accName, cache->AccountId, accountName, accountId);
|
||||
}
|
||||
|
||||
if (player->IsConnected())
|
||||
{
|
||||
player->GetConnectedPlayer()->GetSession()->KickPlayer("CMD char changeaccount");
|
||||
}
|
||||
|
||||
CharacterDatabase.Query("UPDATE characters SET account = {} WHERE guid = {}", accountId, player->GetGUID().GetCounter());
|
||||
sCharacterCache->UpdateCharacterAccountId(player->GetGUID(), accountId);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_character_commandscript()
|
||||
|
||||
Reference in New Issue
Block a user