start building the clear command

This commit is contained in:
Lion Kortlepel 2022-06-28 03:29:01 +02:00
parent 817bd4b588
commit 6e46d5aca9
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B
2 changed files with 11 additions and 1 deletions

View File

@ -35,6 +35,7 @@ private:
void Command_List(const std::string& cmd, const std::vector<std::string>& args);
void Command_Status(const std::string& cmd, const std::vector<std::string>& args);
void Command_Settings(const std::string& cmd, const std::vector<std::string>& args);
void Command_Clear(const std::string&, const std::vector<std::string>& args);
void Command_Say(const std::string& FullCommand);
bool EnsureArgsCount(const std::vector<std::string>& args, size_t n);
@ -50,6 +51,7 @@ private:
{ "list", [this](const auto& a, const auto& b) { Command_List(a, b); } },
{ "status", [this](const auto& a, const auto& b) { Command_Status(a, b); } },
{ "settings", [this](const auto& a, const auto& b) { Command_Settings(a, b); } },
{ "clear", [this](const auto& a, const auto& b) { Command_Clear(a, b); } },
{ "say", [this](const auto&, const auto&) { Command_Say(""); } }, // shouldn't actually be called
};

View File

@ -227,7 +227,8 @@ void TConsole::Command_Help(const std::string&, const std::vector<std::string>&
say <message> sends the message to all players in chat
lua [state id] switches to lua, optionally into a specific state id's lua
settings [command] sets or gets settings for the server, run `settings help` for more info
status how the server is doing and what it's up to)";
status how the server is doing and what it's up to
clear clears the console window)";
Application::Console().WriteRaw("BeamMP-Server Console: " + std::string(sHelpString));
}
@ -240,6 +241,13 @@ std::string TConsole::ConcatArgs(const std::vector<std::string>& args, char spac
return Result;
}
void TConsole::Command_Clear(const std::string&, const std::vector<std::string>& args) {
if (!EnsureArgsCount(args, 0, size_t(-1))) {
return;
}
mCommandline.write("\x1b[;H\x1b[2J");
}
void TConsole::Command_Kick(const std::string&, const std::vector<std::string>& args) {
if (!EnsureArgsCount(args, 1, size_t(-1))) {
return;