[Commands] Cleanup #disablerecipe Command. (#1816)

- Cleanup message and logic.
This commit is contained in:
Kinglykrab 2021-11-23 21:45:59 -05:00 committed by GitHub
parent 8b5b19ae2c
commit 1a2897c423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 24 deletions

View File

@ -152,7 +152,7 @@ int command_init(void)
command_add("depopzone", "- Depop the zone", AccountStatus::GMAdmin, command_depopzone) ||
command_add("devtools", "- Manages devtools", AccountStatus::GMMgmt, command_devtools) ||
command_add("details", "- Change the details of your target (Drakkin Only)", AccountStatus::QuestTroupe, command_details) ||
command_add("disablerecipe", "[recipe_id] - Disables a recipe using the recipe id.", AccountStatus::QuestTroupe, command_disablerecipe) ||
command_add("disablerecipe", "[Recipe ID] - Disables a Recipe", AccountStatus::QuestTroupe, command_disablerecipe) ||
command_add("disarmtrap", "Analog for ldon disarm trap for the newer clients since we still don't have it working.", AccountStatus::QuestTroupe, command_disarmtrap) ||
command_add("distance", "- Reports the distance between you and your target.", AccountStatus::QuestTroupe, command_distance) ||
command_add("door", "Door editing command", AccountStatus::QuestTroupe, command_door) ||

View File

@ -2,28 +2,28 @@
void command_disablerecipe(Client *c, const Seperator *sep)
{
uint32 recipe_id = 0;
bool success = false;
if (c) {
if (sep->argnum == 1) {
recipe_id = atoi(sep->arg[1]);
}
else {
c->Message(Chat::White, "Invalid number of arguments.\nUsage: #disablerecipe recipe_id");
return;
}
if (recipe_id > 0) {
success = content_db.DisableRecipe(recipe_id);
if (success) {
c->Message(Chat::White, "Recipe disabled.");
}
else {
c->Message(Chat::White, "Recipe not disabled.");
}
}
else {
c->Message(Chat::White, "Invalid recipe id.\nUsage: #disablerecipe recipe_id");
}
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #disablerecipe [Recipe ID]");
return;
}
}
auto recipe_id = std::stoul(sep->arg[1]);
if (!recipe_id) {
c->Message(Chat::White, "Usage: #disablerecipe [Recipe ID]");
return;
}
c->Message(
Chat::White,
fmt::format(
"Recipe ID {} {} disabled.",
recipe_id,
(
content_db.DisableRecipe(recipe_id) ?
"successfully" :
"failed to be"
)
).c_str()
);
}