mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Commands] Cleanup #titlesuffix Command. (#1834)
- Cleanup message and logic.
This commit is contained in:
parent
d28f902ecc
commit
5ab9b941e2
@ -369,7 +369,7 @@ int command_init(void)
|
|||||||
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", "[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("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", "[Remove|Title Suffix] [Save (0 = False, 1 = True)] - Set your or your player target's title suffix (use remove to remove title suffix, Save defaults to false if not used)", 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) ||
|
||||||
command_add("tune", "Calculate statistical values related to combat.", AccountStatus::GMAdmin, command_tune) ||
|
command_add("tune", "Calculate statistical values related to combat.", AccountStatus::GMAdmin, command_tune) ||
|
||||||
|
|||||||
@ -3,63 +3,64 @@
|
|||||||
|
|
||||||
void command_titlesuffix(Client *c, const Seperator *sep)
|
void command_titlesuffix(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: #titlesuffix [remove|text] [1 = create row in title table] - remove or set title suffix to 'text'"
|
"Usage: #titlesuffix [Remove|Title] [Save (0 = False, 1 = True)]"
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
bool Save = (atoi(sep->arg[2]) == 1);
|
bool is_remove = !strcasecmp(sep->arg[1], "remove");
|
||||||
|
std::string suffix = is_remove ? "" : sep->arg[1];
|
||||||
Mob *target_mob = c->GetTarget();
|
bool save_suffix = sep->IsNumber(2) ? atobool(sep->arg[2]) : false;
|
||||||
if (!target_mob) {
|
|
||||||
target_mob = c;
|
auto target = c;
|
||||||
}
|
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||||
if (!target_mob->IsClient()) {
|
target = c->GetTarget()->CastToClient();
|
||||||
c->Message(Chat::Red, "#titlesuffix only works on players.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Client *t = target_mob->CastToClient();
|
|
||||||
|
|
||||||
if (strlen(sep->arg[1]) > 31) {
|
|
||||||
c->Message(Chat::Red, "Title suffix must be 31 characters or less.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool removed = false;
|
|
||||||
if (!strcasecmp(sep->arg[1], "remove")) {
|
|
||||||
t->SetTitleSuffix("");
|
|
||||||
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->SetTitleSuffix(sep->arg[1]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
title_manager.CreateNewPlayerSuffix(t, sep->arg[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
t->Save();
|
|
||||||
|
|
||||||
if (removed) {
|
|
||||||
c->Message(Chat::Red, "%s's title suffix has been removed.", t->GetName(), sep->arg[1]);
|
|
||||||
if (t != c) {
|
|
||||||
t->Message(Chat::Red, "Your title suffix has been removed.", sep->arg[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
c->Message(Chat::Red, "%s's title suffix has been changed to '%s'.", t->GetName(), sep->arg[1]);
|
|
||||||
if (t != c) {
|
|
||||||
t->Message(Chat::Red, "Your title suffix has been changed to '%s'.", sep->arg[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (suffix.size() > 31) {
|
||||||
|
c->Message(Chat::White, "Title suffix must be 31 characters or less.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!suffix.empty()) {
|
||||||
|
find_replace(suffix, "_", " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!save_suffix || is_remove) {
|
||||||
|
target->SetTitleSuffix(suffix.c_str());
|
||||||
|
} else if (save_suffix) {
|
||||||
|
title_manager.CreateNewPlayerSuffix(target, suffix.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
target->Save();
|
||||||
|
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Title suffix has been {}{} for {}{}",
|
||||||
|
is_remove ? "removed" : "changed",
|
||||||
|
!is_remove && save_suffix ? " and saved" : "",
|
||||||
|
(
|
||||||
|
c == target ?
|
||||||
|
"yourself" :
|
||||||
|
fmt::format(
|
||||||
|
"{} ({})",
|
||||||
|
target->GetCleanName(),
|
||||||
|
target->GetID()
|
||||||
|
)
|
||||||
|
),
|
||||||
|
(
|
||||||
|
is_remove ?
|
||||||
|
"." :
|
||||||
|
fmt::format(
|
||||||
|
" to '{}'.",
|
||||||
|
suffix
|
||||||
|
)
|
||||||
|
)
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user