diff --git a/zone/command.cpp b/zone/command.cpp index 3a92f24d9..f35a3591c 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -223,7 +223,7 @@ int command_init(void) command_add("kill", "- Kill your target", AccountStatus::GMAdmin, command_kill) || command_add("killallnpcs", " [npc_name] Kills all npcs by search name, leave blank for all attackable NPC's", AccountStatus::GMMgmt, command_killallnpcs) || command_add("lastname", "[Last Name] - Set you or your player target's lastname", AccountStatus::Guide, command_lastname) || - command_add("level", "[level] - Set your or your target's level", AccountStatus::Steward, command_level) || + command_add("level", "[Level] - Set your target's level", AccountStatus::Steward, command_level) || command_add("list", "[npcs|players|corpses|doors|objects] [search] - Search entities", AccountStatus::ApprenticeGuide, command_list) || command_add("listpetition", "- List petitions", AccountStatus::Guide, command_listpetition) || command_add("load_shared_memory", "[shared_memory_name] - Reloads shared memory and uses the input as output", AccountStatus::GMImpossible, command_load_shared_memory) || @@ -746,40 +746,6 @@ void command_zone_instance(Client *c, const Seperator *sep) } } -void command_level(Client *c, const Seperator *sep) -{ - uint16 level = atoi(sep->arg[1]); - - if ((level <= 0) || ((level > RuleI(Character, MaxLevel)) && (c->Admin() < commandLevelAboveCap))) { - c->Message(Chat::White, "Error: #Level: Invalid Level"); - } - else if (c->Admin() < RuleI(GM, MinStatusToLevelTarget)) { - c->SetLevel(level, true); -#ifdef BOTS - if(RuleB(Bots, BotLevelsWithOwner)) - Bot::LevelBotWithClient(c, level, true); -#endif - } - else if (!c->GetTarget()) { - c->Message(Chat::White, "Error: #Level: No target"); - } - else { - if (!c->GetTarget()->IsNPC() && ((c->Admin() < commandLevelNPCAboveCap) && (level > RuleI(Character, MaxLevel)))) { - c->Message(Chat::White, "Error: #Level: Invalid Level"); - } - else { - c->GetTarget()->SetLevel(level, true); - if(c->GetTarget()->IsClient()) { - c->GetTarget()->CastToClient()->SendLevelAppearance(); -#ifdef BOTS - if(RuleB(Bots, BotLevelsWithOwner)) - Bot::LevelBotWithClient(c->GetTarget()->CastToClient(), level, true); -#endif - } - } - } -} - void command_spawneditmass(Client *c, const Seperator *sep) { std::string query = fmt::format( @@ -1235,6 +1201,7 @@ void command_bot(Client *c, const Seperator *sep) #include "gm_commands/kill.cpp" #include "gm_commands/killallnpcs.cpp" #include "gm_commands/lastname.cpp" +#include "gm_commands/level.cpp" #include "gm_commands/list.cpp" #include "gm_commands/listpetition.cpp" #include "gm_commands/loc.cpp" diff --git a/zone/gm_commands/level.cpp b/zone/gm_commands/level.cpp new file mode 100644 index 000000000..77203e6a2 --- /dev/null +++ b/zone/gm_commands/level.cpp @@ -0,0 +1,51 @@ +#include "../client.h" + +void command_level(Client *c, const Seperator *sep) +{ + int arguments = sep->argnum; + if (!arguments || !sep->IsNumber(1)) { + c->Message(Chat::White, "Usage: #level [Level]"); + return; + } + + auto target = c->GetTarget(); + if (!target) { + c->Message(Chat::White, "You must have a target to use this command."); + return; + } + + auto level = static_cast(std::stoul(sep->arg[1])); + auto max_level = static_cast(RuleI(Character, MaxLevel)); + + if (c->Admin() < RuleI(GM, MinStatusToLevelTarget)) { + c->Message(Chat::White, "Your status is not high enough to change another person's level."); + return; + } + + if ( + level > max_level && + c->Admin() < commandLevelAboveCap + ) { + c->Message( + Chat::White, + fmt::format( + "Level {} is above the Maximum Level of {} and your status is not high enough to go beyond the cap.", + level, + max_level + ).c_str() + ); + return; + } + + target->SetLevel(level, true); + if (target->IsClient()) { + target->CastToClient()->SendLevelAppearance(); + +#ifdef BOTS + if (RuleB(Bots, BotLevelsWithOwner)) { + Bot::LevelBotWithClient(target->CastToClient(), level, true); + } +#endif + + } +} \ No newline at end of file