[Commands] Cleanup #serverrules Command. (#2139)

- Cleanup messages and logic.
- Change separator from new line to pipe separator, as new line was non-functional.
This commit is contained in:
Kinglykrab 2022-05-06 19:50:09 -04:00 committed by GitHub
parent e5acc7c322
commit e2bfa44df0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 15 deletions

View File

@ -3897,31 +3897,50 @@ void Client::GetRaidAAs(RaidLeadershipAA_Struct *into) const {
void Client::EnteringMessages(Client* client)
{
//server rules
std::string rules;
if(database.GetVariable("Rules", rules))
{
if (database.GetVariable("Rules", rules)) {
uint8 flag = database.GetAgreementFlag(client->AccountID());
if(!flag)
{
client->Message(Chat::Red,"You must agree to the Rules, before you can move. (type #serverrules to view the rules)");
client->Message(Chat::Red,"You must agree to the Rules, before you can move. (type #serverrules to view the rules)");
client->Message(Chat::Red,"You must agree to the Rules, before you can move. (type #serverrules to view the rules)");
if (!flag) {
auto rules_link = EQ::SayLinkEngine::GenerateQuestSaylink(
"#serverrules",
false,
"rules"
);
client->Message(
Chat::White,
fmt::format(
"You must agree to the {} before you can move.",
rules_link
).c_str()
);
client->SendAppearancePacket(AT_Anim, ANIM_FREEZE);
}
}
}
void Client::SendRules(Client* client)
void Client::SendRules()
{
std::string rules;
if (!database.GetVariable("Rules", rules))
if (!database.GetVariable("Rules", rules)) {
return;
}
auto lines = SplitString(rules, '\n');
for (auto&& e : lines)
client->Message(Chat::White, "%s", e.c_str());
auto lines = split_string(rules, "|");
auto line_number = 1;
for (auto&& line : lines) {
Message(
Chat::White,
fmt::format(
"{}. {}",
line_number,
line
).c_str()
);
line_number++;
}
}
void Client::SetEndurance(int32 newEnd)

View File

@ -1035,7 +1035,7 @@ public:
void RemoveTitle(int titleset);
void EnteringMessages(Client* client);
void SendRules(Client* client);
void SendRules();
const bool GetGMSpeed() const { return (gmspeed > 0); }
bool CanUseReport;

View File

@ -2,6 +2,6 @@
void command_serverrules(Client *c, const Seperator *sep)
{
c->SendRules(c);
c->SendRules();
}