mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Commands] Add #findlanguage Command (#3434)
# Notes - Add `#findlanguage` command.
This commit is contained in:
parent
d558f9ece2
commit
9154c90418
@ -143,6 +143,7 @@ int command_init(void)
|
||||
command_add("findclass", "[Search Criteria] - Search for a class", AccountStatus::Guide, command_findclass) ||
|
||||
command_add("findcurrency", "[Search Criteria] - Search for an alternate currency", AccountStatus::Guide, command_findcurrency) ||
|
||||
command_add("findfaction", "[Search Criteria] - Search for a faction", AccountStatus::Guide, command_findfaction) ||
|
||||
command_add("findlanguage", "[Search Criteria] - Search for a language", AccountStatus::Guide, command_findlanguage) ||
|
||||
command_add("findnpctype", "[Search Criteria] - Search database NPC types", AccountStatus::GMAdmin, command_findnpctype) ||
|
||||
command_add("findrace", "[Search Criteria] - Search for a race", AccountStatus::Guide, command_findrace) ||
|
||||
command_add("findrecipe", "[Search Criteria] - Search for a recipe", AccountStatus::Guide, command_findrecipe) ||
|
||||
@ -985,6 +986,7 @@ void command_bot(Client *c, const Seperator *sep)
|
||||
#include "gm_commands/findclass.cpp"
|
||||
#include "gm_commands/findcurrency.cpp"
|
||||
#include "gm_commands/findfaction.cpp"
|
||||
#include "gm_commands/findlanguage.cpp"
|
||||
#include "gm_commands/findnpctype.cpp"
|
||||
#include "gm_commands/findrace.cpp"
|
||||
#include "gm_commands/findrecipe.cpp"
|
||||
|
||||
@ -93,6 +93,7 @@ void command_findcharacter(Client *c, const Seperator *sep);
|
||||
void command_findclass(Client *c, const Seperator *sep);
|
||||
void command_findcurrency(Client *c, const Seperator *sep);
|
||||
void command_findfaction(Client *c, const Seperator *sep);
|
||||
void command_findlanguage(Client *c, const Seperator *sep);
|
||||
void command_findnpctype(Client *c, const Seperator *sep);
|
||||
void command_findrace(Client *c, const Seperator *sep);
|
||||
void command_findrecipe(Client *c, const Seperator *sep);
|
||||
|
||||
77
zone/gm_commands/findlanguage.cpp
Executable file
77
zone/gm_commands/findlanguage.cpp
Executable file
@ -0,0 +1,77 @@
|
||||
#include "../client.h"
|
||||
#include "../../common/languages.h"
|
||||
|
||||
void command_findlanguage(Client *c, const Seperator *sep)
|
||||
{
|
||||
const auto arguments = sep->argnum;
|
||||
if (!arguments) {
|
||||
c->Message(Chat::White, "Command Syntax: #findlanguage [Search Criteria]");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sep->IsNumber(1)) {
|
||||
const auto language_id = Strings::ToInt(sep->arg[1]);
|
||||
if (EQ::ValueWithin(language_id, LANG_COMMON_TONGUE, LANG_UNKNOWN)) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Language {} | {}",
|
||||
language_id,
|
||||
EQ::constants::GetLanguageName(language_id)
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Language ID {} was not found.",
|
||||
language_id
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[1]);
|
||||
if (!search_criteria.empty()) {
|
||||
const auto& m = EQ::constants::GetLanguageMap();
|
||||
auto found_count = 0;
|
||||
for (const auto& l : m) {
|
||||
const auto& language_name_lower = Strings::ToLower(l.second);
|
||||
if (Strings::Contains(language_name_lower, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Language {} | {}",
|
||||
l.first,
|
||||
l.second
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
}
|
||||
|
||||
auto language_message = (
|
||||
found_count > 0 ?
|
||||
(
|
||||
found_count == 1 ?
|
||||
"A Language was" :
|
||||
fmt::format("{} Languages were", found_count)
|
||||
) :
|
||||
"No Languages were"
|
||||
);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} found.",
|
||||
language_message
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user