mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-26 11:27:17 +00:00
[Feature] Add Character Auto Login (#4216)
* [Feature] Add Character Auto Login * Add commands and finalize. * Add methods without character name. * Update perl_client.cpp * Add other methods. * Repository methods. * Update account_repository.h * Update command_subsettings_repository.h * Update command_subsettings_repository.h * Update client.cpp
This commit is contained in:
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#include "../../client.h"
|
||||
#include "../../groups.h"
|
||||
#include "../../raids.h"
|
||||
#include "../../raids.h"
|
||||
#include "../../common/repositories/account_repository.h"
|
||||
|
||||
void SetAutoLogin(Client* c, const Seperator* sep)
|
||||
{
|
||||
if (!RuleB(World, EnableAutoLogin)) {
|
||||
c->Message(Chat::White, "Auto login is disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint16 arguments = sep->argnum;
|
||||
if (arguments < 2 || !sep->IsNumber(2)) {
|
||||
c->Message(Chat::White, "Usage: #set auto_login [0|1]");
|
||||
c->Message(Chat::White, "0 = Disable auto login for your account");
|
||||
c->Message(Chat::White, "1 = Set auto login character to your current character");
|
||||
return;
|
||||
}
|
||||
|
||||
Client* t = c;
|
||||
if (c->GetGM() && c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||
t = c->GetTarget()->CastToClient();
|
||||
}
|
||||
|
||||
auto e = AccountRepository::FindOne(database, t->AccountID());
|
||||
|
||||
if (!e.id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Failed to find an account entry for {}.",
|
||||
c->GetTargetDescription(t)
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const bool set_login = Strings::ToBool(sep->arg[2]);
|
||||
|
||||
e.auto_login_charname = set_login ? t->GetCleanName() : std::string();
|
||||
|
||||
AccountRepository::UpdateOne(database, e);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Auto login character has been set to '{}' for {}.",
|
||||
e.auto_login_charname,
|
||||
c->GetTargetDescription(t)
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user