mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
[Commands] Cleanup #title Command. (#1833)
- Cleanup message and logic.
This commit is contained in:
parent
8688e9c9fa
commit
96cdf1b076
@ -364,7 +364,7 @@ int command_init(void)
|
|||||||
command_add("time", "[HH] [MM] - Set EQ time", AccountStatus::EQSupport, command_time) ||
|
command_add("time", "[HH] [MM] - Set EQ time", AccountStatus::EQSupport, command_time) ||
|
||||||
command_add("timers", "- Display persistent timers for target", AccountStatus::GMMgmt, command_timers) ||
|
command_add("timers", "- Display persistent timers for target", AccountStatus::GMMgmt, command_timers) ||
|
||||||
command_add("timezone", "[HH] [MM] - Set timezone. Minutes are optional", AccountStatus::EQSupport, command_timezone) ||
|
command_add("timezone", "[HH] [MM] - Set timezone. Minutes are optional", AccountStatus::EQSupport, command_timezone) ||
|
||||||
command_add("title", "[text] [1 = create title table row] - Set your or your player target's title", AccountStatus::Guide, command_title) ||
|
command_add("title", "[Remove|Title] [Save (0 = False, 1 = True)] - Set your or your player target's title (use remove to remove title, Save defaults to false if not used)", AccountStatus::Guide, command_title) ||
|
||||||
command_add("titlesuffix", "[text] [1 = create title table row] - Set your or your player target's title suffix", AccountStatus::Guide, command_titlesuffix) ||
|
command_add("titlesuffix", "[text] [1 = create title table row] - Set your or your player target's title suffix", AccountStatus::Guide, command_titlesuffix) ||
|
||||||
command_add("traindisc", "[level] - Trains all the disciplines usable by the target, up to level specified. (may freeze client for a few seconds)", AccountStatus::GMLeadAdmin, command_traindisc) ||
|
command_add("traindisc", "[level] - Trains all the disciplines usable by the target, up to level specified. (may freeze client for a few seconds)", AccountStatus::GMLeadAdmin, command_traindisc) ||
|
||||||
command_add("trapinfo", "- Gets infomation about the traps currently spawned in the zone.", AccountStatus::QuestTroupe, command_trapinfo) ||
|
command_add("trapinfo", "- Gets infomation about the traps currently spawned in the zone.", AccountStatus::QuestTroupe, command_trapinfo) ||
|
||||||
|
|||||||
@ -3,63 +3,66 @@
|
|||||||
|
|
||||||
void command_title(Client *c, const Seperator *sep)
|
void command_title(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
if (sep->arg[1][0] == 0) {
|
int arguments = sep->argnum;
|
||||||
|
if (!arguments) {
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
"Usage: #title [remove|text] [1 = Create row in title table] - remove or set title to 'text'"
|
"Usage: #title [Remove|Title] [Save (0 = False, 1 = True)]"
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
bool Save = (atoi(sep->arg[2]) == 1);
|
|
||||||
|
|
||||||
Mob *target_mob = c->GetTarget();
|
bool is_remove = !strcasecmp(sep->arg[1], "remove");
|
||||||
if (!target_mob) {
|
std::string title = is_remove ? "" : sep->arg[1];
|
||||||
target_mob = c;
|
bool save_title = sep->IsNumber(2) ? atobool(sep->arg[2]) : false;
|
||||||
}
|
|
||||||
if (!target_mob->IsClient()) {
|
|
||||||
c->Message(Chat::Red, "#title only works on players.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Client *t = target_mob->CastToClient();
|
|
||||||
|
|
||||||
if (strlen(sep->arg[1]) > 31) {
|
auto target = c;
|
||||||
c->Message(Chat::Red, "Title must be 31 characters or less.");
|
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||||
return;
|
target = c->GetTarget()->CastToClient();
|
||||||
}
|
|
||||||
|
|
||||||
bool removed = false;
|
|
||||||
if (!strcasecmp(sep->arg[1], "remove")) {
|
|
||||||
t->SetAATitle("");
|
|
||||||
removed = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (unsigned int i = 0; i < strlen(sep->arg[1]); i++)
|
|
||||||
if (sep->arg[1][i] == '_') {
|
|
||||||
sep->arg[1][i] = ' ';
|
|
||||||
}
|
|
||||||
if (!Save) {
|
|
||||||
t->SetAATitle(sep->arg[1]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
title_manager.CreateNewPlayerTitle(t, sep->arg[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
t->Save();
|
|
||||||
|
|
||||||
if (removed) {
|
|
||||||
c->Message(Chat::Red, "%s's title has been removed.", t->GetName(), sep->arg[1]);
|
|
||||||
if (t != c) {
|
|
||||||
t->Message(Chat::Red, "Your title has been removed.", sep->arg[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
c->Message(Chat::Red, "%s's title has been changed to '%s'.", t->GetName(), sep->arg[1]);
|
|
||||||
if (t != c) {
|
|
||||||
t->Message(Chat::Red, "Your title has been changed to '%s'.", sep->arg[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (title.size() > 31) {
|
||||||
|
c->Message(Chat::White, "Title must be 31 characters or less.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!title.empty()) {
|
||||||
|
find_replace(title, "_", " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!save_title || is_remove) {
|
||||||
|
target->SetAATitle(title.c_str());
|
||||||
|
} else if (save_title) {
|
||||||
|
title_manager.CreateNewPlayerTitle(target, title.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
target->Save();
|
||||||
|
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Title has been {}{} for {}{}",
|
||||||
|
is_remove ? "removed" : "changed",
|
||||||
|
!is_remove && save_title ? " and saved" : "",
|
||||||
|
(
|
||||||
|
c == target ?
|
||||||
|
"yourself" :
|
||||||
|
fmt::format(
|
||||||
|
"{} ({})",
|
||||||
|
target->GetCleanName(),
|
||||||
|
target->GetID()
|
||||||
|
)
|
||||||
|
),
|
||||||
|
(
|
||||||
|
is_remove ?
|
||||||
|
"." :
|
||||||
|
fmt::format(
|
||||||
|
" to '{}'.",
|
||||||
|
title
|
||||||
|
)
|
||||||
|
)
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user