[Commands] Cleanup #chat Command. (#2581)

- Cleanup messages and logic.
This commit is contained in:
Alex King 2022-11-26 19:28:28 -05:00 committed by GitHub
parent f7ae5850f0
commit 253f4c07e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -108,7 +108,7 @@ int command_init(void)
command_add("camerashake", "[Duration (Milliseconds)] [Intensity (1-10)] - Shakes the camera on everyone's screen globally.", AccountStatus::QuestTroupe, command_camerashake) ||
command_add("castspell", "[Spell ID] [Instant (0 = False, 1 = True, Default is 1 if Unused)] - Cast a spell", AccountStatus::Guide, command_castspell) ||
command_add("chat", "[channel num] [message] - Send a channel message to all zones", AccountStatus::GMMgmt, command_chat) ||
command_add("chat", "[Channel ID] [Message] - Send a channel message to all zones", AccountStatus::GMMgmt, command_chat) ||
command_add("checklos", "Check for line of sight to your target", AccountStatus::Guide, command_checklos) ||
command_add("copycharacter", "[source_char_name] [dest_char_name] [dest_account_name] - Copies character to destination account", AccountStatus::GMImpossible, command_copycharacter) ||
command_add("corpse", "Manipulate corpses, use with no arguments for help", AccountStatus::Guide, command_corpse) ||

View File

@ -5,11 +5,16 @@ extern WorldServer worldserver;
void command_chat(Client *c, const Seperator *sep)
{
if (sep->arg[2][0] == 0) {
c->Message(Chat::White, "Usage: #chat [channum] [message]");
auto arguments = sep->argnum;
if (arguments < 2 || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #chat [Channel ID] [Message]");
return;
}
else if (!worldserver.SendChannelMessage(0, 0, (uint8) atoi(sep->arg[1]), 0, 0, 100, sep->argplus[2])) {
c->Message(Chat::White, "Error: World server disconnected");
auto channel_id = static_cast<uint8>(std::stoul(sep->arg[1]));
std::string message = sep->argplus[2];
if (!worldserver.SendChannelMessage(0, 0, channel_id, 0, 0, 100, message.c_str())) {
c->Message(Chat::White, "World server is disconnected.");
}
}