mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-30 00:53:46 +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:
@@ -0,0 +1,8 @@
|
|||||||
|
--
|
||||||
|
DELETE FROM `acore_string` WHERE `entry` = 5083;
|
||||||
|
INSERT INTO `acore_string` (`entry`, `content_default`) VALUES
|
||||||
|
(5083, 'Character %s (%u) moved from account %s (%u) to account %s (%u).');
|
||||||
|
|
||||||
|
DELETE FROM `command` WHERE `name` = 'character changeaccount';
|
||||||
|
INSERT INTO `command` (`name`, `security`, `help`) VALUES
|
||||||
|
('character changeaccount', 3, 'Syntax: .character changeaccount $NewAccountName $Name.\nMoves the specified character to the provided account. \nKicks the player if the character is online.');
|
||||||
@@ -1146,6 +1146,8 @@ enum AcoreStrings
|
|||||||
|
|
||||||
LANG_CMD_GOQUEST_INVALID_SYNTAX = 5082,
|
LANG_CMD_GOQUEST_INVALID_SYNTAX = 5082,
|
||||||
|
|
||||||
|
LANG_CMD_CHAR_CHANGE_ACC_SUCCESS = 5083,
|
||||||
|
|
||||||
// Room for more strings 5083-9999
|
// Room for more strings 5083-9999
|
||||||
|
|
||||||
// Level requirement notifications
|
// Level requirement notifications
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public:
|
|||||||
{ "customize", HandleCharacterCustomizeCommand, SEC_GAMEMASTER, Console::Yes },
|
{ "customize", HandleCharacterCustomizeCommand, SEC_GAMEMASTER, Console::Yes },
|
||||||
{ "changefaction", HandleCharacterChangeFactionCommand, SEC_GAMEMASTER, Console::Yes },
|
{ "changefaction", HandleCharacterChangeFactionCommand, SEC_GAMEMASTER, Console::Yes },
|
||||||
{ "changerace", HandleCharacterChangeRaceCommand, SEC_GAMEMASTER, Console::Yes },
|
{ "changerace", HandleCharacterChangeRaceCommand, SEC_GAMEMASTER, Console::Yes },
|
||||||
|
{ "changeaccount", HandleCharacterChangeAccountCommand, SEC_ADMINISTRATOR, Console::Yes },
|
||||||
{ "check", characterCheckCommandTable },
|
{ "check", characterCheckCommandTable },
|
||||||
{ "erase", HandleCharacterEraseCommand, SEC_CONSOLE, Console::Yes },
|
{ "erase", HandleCharacterEraseCommand, SEC_CONSOLE, Console::Yes },
|
||||||
{ "deleted", characterDeletedCommandTable },
|
{ "deleted", characterDeletedCommandTable },
|
||||||
@@ -1061,6 +1062,55 @@ public:
|
|||||||
handler->PSendSysMessage("--------------------------------------");
|
handler->PSendSysMessage("--------------------------------------");
|
||||||
return true;
|
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()
|
void AddSC_character_commandscript()
|
||||||
|
|||||||
Reference in New Issue
Block a user