mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
* [Commands] Add #suspendmulti Command. # Notes - Allows operators to suspend multiple people at once in case they have a player who is boxing and want to suspend them all at once. * To lower. * Update command.cpp * Update suspendmulti.cpp * Create suspendmulti.cpp
94 lines
2.0 KiB
C++
Executable File
94 lines
2.0 KiB
C++
Executable File
#include "../client.h"
|
|
#include "../worldserver.h"
|
|
#include "../../common/repositories/account_repository.h"
|
|
|
|
extern WorldServer worldserver;
|
|
|
|
void command_suspendmulti(Client *c, const Seperator *sep)
|
|
{
|
|
auto arguments = sep->argnum;
|
|
if (arguments < 2 || !sep->IsNumber(2)) {
|
|
c->Message(Chat::White, "Usage: #suspendmulti [Character Name|Character Name Two|etc] [Days] [Reason]");
|
|
c->Message(Chat::White, "Note: Specify 0 days to lift a suspension");
|
|
return;
|
|
}
|
|
|
|
const auto& n = Strings::Split(sep->arg[1], "|");
|
|
std::vector<std::string> v;
|
|
for (const auto& c : n) {
|
|
v.push_back(fmt::format("'{}'", Strings::ToLower(c)));
|
|
}
|
|
|
|
auto days = std::stoul(sep->arg[2]);
|
|
|
|
const std::string reason = sep->arg[3] ? sep->argplus[3] : "";
|
|
|
|
auto l = AccountRepository::GetWhere(
|
|
database,
|
|
fmt::format(
|
|
"LOWER(charname) IN ({})",
|
|
Strings::Implode(", ", v)
|
|
)
|
|
);
|
|
|
|
if (l.empty()) {
|
|
c->Message(Chat::White, "No characters found.");
|
|
return;
|
|
}
|
|
|
|
for (auto a : l) {
|
|
a.status = -1;
|
|
a.suspendeduntil = std::time(nullptr) + (days * 86400);
|
|
a.suspend_reason = reason;
|
|
|
|
if (!AccountRepository::UpdateOne(database, a)) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Failed to suspend Account {} ({}).",
|
|
a.name,
|
|
a.id
|
|
).c_str()
|
|
);
|
|
return;
|
|
}
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Account {} ({}) {}.",
|
|
a.name,
|
|
a.id,
|
|
(
|
|
days ?
|
|
fmt::format(
|
|
"has been temporarily suspended for {} day{}.",
|
|
days,
|
|
days != 1 ? "s" : ""
|
|
) :
|
|
"is no longer suspended"
|
|
)
|
|
).c_str()
|
|
);
|
|
|
|
auto *b = entity_list.GetClientByAccID(a.id);
|
|
|
|
if (b) {
|
|
b->WorldKick();
|
|
return;
|
|
}
|
|
|
|
auto pack = new ServerPacket(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct));
|
|
auto *k = (ServerKickPlayer_Struct *) pack->pBuffer;
|
|
|
|
strn0cpy(k->adminname, c->GetName(), sizeof(k->adminname));
|
|
k->account_id = a.id;
|
|
k->adminrank = c->Admin();
|
|
|
|
worldserver.SendPacket(pack);
|
|
|
|
safe_delete(pack);
|
|
}
|
|
}
|
|
|