mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-16 22:18:20 +00:00
[Commands] Cleanup #ban, #ipban, #flag, #kick, #setlsinfo, and #setpass Commands. (#2104)
* [Commands] Cleanup #ban, #ipban, #flag, and #kick Commands. - Cleanup messages and logic. - Add ServerFlagUpdate_Struct for flag updates. * Add #setlsinfo and #setpass to cleanup. * Update setlsinfo.cpp * Update database.cpp * Update database.cpp * Update command.cpp
This commit is contained in:
@@ -2,28 +2,50 @@
|
||||
|
||||
void command_setpass(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->argnum != 2) {
|
||||
c->Message(Chat::White, "Format: #setpass accountname password");
|
||||
int arguments = sep->argnum;
|
||||
if (arguments < 2) {
|
||||
c->Message(Chat::White, "Usage: #setpass [Account Name] [Password]");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
std::string user;
|
||||
std::string loginserver;
|
||||
ParseAccountString(sep->arg[1], user, loginserver);
|
||||
|
||||
int16 tmpstatus = 0;
|
||||
uint32 tmpid = database.GetAccountIDByName(user.c_str(), loginserver.c_str(), &tmpstatus);
|
||||
if (!tmpid) {
|
||||
c->Message(Chat::White, "Error: Account not found");
|
||||
}
|
||||
else if (tmpstatus > c->Admin()) {
|
||||
c->Message(Chat::White, "Cannot change password: Account's status is higher than yours");
|
||||
}
|
||||
else if (database.SetLocalPassword(tmpid, sep->arg[2])) {
|
||||
c->Message(Chat::White, "Password changed.");
|
||||
}
|
||||
else {
|
||||
c->Message(Chat::White, "Error changing password.");
|
||||
}
|
||||
std::string account_name;
|
||||
std::string loginserver;
|
||||
ParseAccountString(sep->arg[1], account_name, loginserver);
|
||||
int16 status = 0;
|
||||
auto account_id = database.GetAccountIDByName(account_name, loginserver, &status);
|
||||
if (!account_id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Account {} not found.",
|
||||
account_name
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (status > c->Admin()) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"You cannot change the password for Account {} as its status is higher than yours.",
|
||||
account_name
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Password {} changed for Account {}.",
|
||||
(
|
||||
database.SetLocalPassword(account_id, sep->arg[2]) ?
|
||||
"successfully" :
|
||||
"failed"
|
||||
),
|
||||
account_name
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user