From e08afb1234253b47dc950cf3e799df63d44d2fa0 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Tue, 3 May 2022 23:05:02 -0400 Subject: [PATCH] [Commands] Cleanup #getvariable Command. (#2100) - Cleanup messages and logic. --- zone/command.cpp | 2 +- zone/gm_commands/getvariable.cpp | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index efe6b1a2a..336cd9e59 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -192,7 +192,7 @@ int command_init(void) command_add("gearup", "Developer tool to quickly equip a character", AccountStatus::GMMgmt, command_gearup) || command_add("gender", "[0/1/2] - Change your or your target's gender to male/female/neuter", AccountStatus::Guide, command_gender) || command_add("getplayerburiedcorpsecount", "- Get your or your target's total number of buried player corpses.", AccountStatus::GMAdmin, command_getplayerburiedcorpsecount) || - command_add("getvariable", "[varname] - Get the value of a variable from the database", AccountStatus::GMMgmt, command_getvariable) || + command_add("getvariable", "[Variable Name] - Get the value of a variable from the database", AccountStatus::GMMgmt, command_getvariable) || command_add("ginfo", "- get group info on target.", AccountStatus::ApprenticeGuide, command_ginfo) || command_add("giveitem", "[itemid] [charges] - Summon an item onto your target's cursor. Charges are optional.", AccountStatus::GMMgmt, command_giveitem) || command_add("givemoney", "[Platinum] [Gold] [Silver] [Copper] - Gives specified amount of money to you or your player target", AccountStatus::GMMgmt, command_givemoney) || diff --git a/zone/gm_commands/getvariable.cpp b/zone/gm_commands/getvariable.cpp index 23c90219e..7b26ccfb0 100755 --- a/zone/gm_commands/getvariable.cpp +++ b/zone/gm_commands/getvariable.cpp @@ -2,12 +2,30 @@ void command_getvariable(Client *c, const Seperator *sep) { - std::string tmp; - if (database.GetVariable(sep->argplus[1], tmp)) { - c->Message(Chat::White, "%s = %s", sep->argplus[1], tmp.c_str()); + std::string variable = sep->argplus[1]; + if (variable.empty()) { + c->Message(Chat::White, "Usage: #getvariable [Variable Name]"); + return; } - else { - c->Message(Chat::White, "GetVariable(%s) returned false", sep->argplus[1]); + + std::string message; + std::string value; + if (database.GetVariable(variable, value)) { + message = fmt::format( + "Variable {}: {}", + variable, + value + ); + } else { + message = fmt::format( + "Variable '{}' does not exist.", + variable + ); } + + c->Message( + Chat::White, + message.c_str() + ); }