[Commands] Cleanup #gassign Command. (#2101)

* [Commands] Cleanup #gassign Command.
- Cleanup messages and logic.

* Update gassign.cpp

* Update gassign.cpp
This commit is contained in:
Kinglykrab
2022-05-06 19:13:28 -04:00
committed by GitHub
parent 8dcc810b43
commit fc484d0b1c
4 changed files with 39 additions and 17 deletions
+15 -6
View File
@@ -2,13 +2,22 @@
void command_gassign(Client *c, const Seperator *sep)
{
if (sep->IsNumber(1) && c->GetTarget() && c->GetTarget()->IsNPC() &&
c->GetTarget()->CastToNPC()->GetSpawnPointID() > 0) {
int spawn2id = c->GetTarget()->CastToNPC()->GetSpawnPointID();
database.AssignGrid(c, atoi(sep->arg[1]), spawn2id);
if (!c->GetTarget() || !c->GetTarget()->IsNPC()) {
c->Message(Chat::White, "You must target an NPC to use this command.");
return;
}
else {
c->Message(Chat::White, "Usage: #gassign [num] - must have an npc target!");
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #gassign [Grid ID]");
return;
}
auto grid_id = std::stoul(sep->arg[1]);
auto target = c->GetTarget()->CastToNPC();
if (target->GetSpawnPointID() > 0) {
database.AssignGrid(c, grid_id, target->GetID());
}
}