mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Commands] Add #countitem Command. (#1842)
* [Commands] Add #countitem Command. - Add #countitem [Item ID] command to count an item by ID on yourself or your player/NPC target. * Cleanup.
This commit is contained in:
parent
fd862d16bb
commit
d28f902ecc
@ -308,6 +308,7 @@ SET(gm_commands
|
|||||||
gm_commands/copycharacter.cpp
|
gm_commands/copycharacter.cpp
|
||||||
gm_commands/corpse.cpp
|
gm_commands/corpse.cpp
|
||||||
gm_commands/corpsefix.cpp
|
gm_commands/corpsefix.cpp
|
||||||
|
gm_commands/countitem.cpp
|
||||||
gm_commands/cvs.cpp
|
gm_commands/cvs.cpp
|
||||||
gm_commands/damage.cpp
|
gm_commands/damage.cpp
|
||||||
gm_commands/databuckets.cpp
|
gm_commands/databuckets.cpp
|
||||||
|
|||||||
@ -140,6 +140,7 @@ int command_init(void)
|
|||||||
command_add("copycharacter", "[source_char_name] [dest_char_name] [dest_account_name] Copies character to destination account", AccountStatus::GMImpossible, command_copycharacter) ||
|
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) ||
|
command_add("corpse", "- Manipulate corpses, use with no arguments for help", AccountStatus::Guide, command_corpse) ||
|
||||||
command_add("corpsefix", "Attempts to bring corpses from underneath the ground within close proximity of the player", AccountStatus::Player, command_corpsefix) ||
|
command_add("corpsefix", "Attempts to bring corpses from underneath the ground within close proximity of the player", AccountStatus::Player, command_corpsefix) ||
|
||||||
|
command_add("countitem", "[Item ID] - Counts the specified Item ID in your or your target's inventory", AccountStatus::GMLeadAdmin, command_countitem) ||
|
||||||
command_add("cvs", "- Summary of client versions currently online.", AccountStatus::GMMgmt, command_cvs) ||
|
command_add("cvs", "- Summary of client versions currently online.", AccountStatus::GMMgmt, command_cvs) ||
|
||||||
command_add("damage", "[Amount] - Damage yourself or your target", AccountStatus::GMAdmin, command_damage) ||
|
command_add("damage", "[Amount] - Damage yourself or your target", AccountStatus::GMAdmin, command_damage) ||
|
||||||
command_add("databuckets", "View|Delete [key] [limit]- View data buckets, limit 50 default or Delete databucket by key", AccountStatus::QuestTroupe, command_databuckets) ||
|
command_add("databuckets", "View|Delete [key] [limit]- View data buckets, limit 50 default or Delete databucket by key", AccountStatus::QuestTroupe, command_databuckets) ||
|
||||||
|
|||||||
@ -48,6 +48,7 @@ void command_checklos(Client *c, const Seperator *sep);
|
|||||||
void command_copycharacter(Client *c, const Seperator *sep);
|
void command_copycharacter(Client *c, const Seperator *sep);
|
||||||
void command_corpse(Client *c, const Seperator *sep);
|
void command_corpse(Client *c, const Seperator *sep);
|
||||||
void command_corpsefix(Client *c, const Seperator *sep);
|
void command_corpsefix(Client *c, const Seperator *sep);
|
||||||
|
void command_countitem(Client *c, const Seperator *sep);
|
||||||
void command_cvs(Client *c, const Seperator *sep);
|
void command_cvs(Client *c, const Seperator *sep);
|
||||||
void command_damage(Client *c, const Seperator *sep);
|
void command_damage(Client *c, const Seperator *sep);
|
||||||
void command_databuckets(Client *c, const Seperator *sep);
|
void command_databuckets(Client *c, const Seperator *sep);
|
||||||
|
|||||||
64
zone/gm_commands/countitem.cpp
Normal file
64
zone/gm_commands/countitem.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#include "../client.h"
|
||||||
|
|
||||||
|
void command_countitem(Client *c, const Seperator *sep)
|
||||||
|
{
|
||||||
|
int arguments = sep->argnum;
|
||||||
|
if (!arguments || !sep->IsNumber(1)) {
|
||||||
|
c->Message(Chat::White, "Usage: #countitem [Item ID]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mob* target = c;
|
||||||
|
if (
|
||||||
|
c->GetTarget() &&
|
||||||
|
(
|
||||||
|
c->GetTarget()->IsClient() ||
|
||||||
|
c->GetTarget()->IsNPC()
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
target = c->GetTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto item_id = std::stoul(sep->arg[1]);
|
||||||
|
if (!database.GetItem(item_id)) {
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Item ID {} could not be found.",
|
||||||
|
item_id
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 item_count = 0;
|
||||||
|
if (target->IsClient()) {
|
||||||
|
item_count = target->CastToClient()->CountItem(item_id);
|
||||||
|
} else if (target->IsNPC()) {
|
||||||
|
item_count = target->CastToNPC()->CountItem(item_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"{} {} {} {}.",
|
||||||
|
(
|
||||||
|
c == target ?
|
||||||
|
"You" :
|
||||||
|
fmt::format(
|
||||||
|
"{} ({})",
|
||||||
|
target->GetCleanName(),
|
||||||
|
target->GetID()
|
||||||
|
)
|
||||||
|
),
|
||||||
|
c == target ? "have" : "has",
|
||||||
|
(
|
||||||
|
item_count ?
|
||||||
|
std::to_string(item_count) :
|
||||||
|
"no"
|
||||||
|
),
|
||||||
|
database.CreateItemLink(item_id)
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user