mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Commands] Cleanup #name Command. (#1977)
- Cleanup messages and logic.
This commit is contained in:
parent
968ae26c99
commit
5396c0c88b
@ -252,7 +252,7 @@ int command_init(void)
|
||||
command_add("myskills", "- Show details about your current skill levels", AccountStatus::Player, command_myskills) ||
|
||||
command_add("mysql", "[Help|Query] [SQL Query] - Mysql CLI, see 'Help' for options.", AccountStatus::GMImpossible, command_mysql) ||
|
||||
command_add("mystats", "- Show details about you or your pet", AccountStatus::Guide, command_mystats) ||
|
||||
command_add("name", "[newname] - Rename your player target", AccountStatus::GMLeadAdmin, command_name) ||
|
||||
command_add("name", "[New Name] - Rename your player target", AccountStatus::GMLeadAdmin, command_name) ||
|
||||
command_add("netstats", "- Gets the network stats for a stream.", AccountStatus::GMMgmt, command_netstats) ||
|
||||
command_add("network", "- Admin commands for the udp network interface.", AccountStatus::GMImpossible, command_network) ||
|
||||
command_add("npccast", "[targetname/entityid] [spellid] - Causes NPC target to cast spellid on targetname/entityid", AccountStatus::QuestTroupe, command_npccast) ||
|
||||
|
||||
@ -2,29 +2,41 @@
|
||||
|
||||
void command_name(Client *c, const Seperator *sep)
|
||||
{
|
||||
Client *target;
|
||||
|
||||
if ((strlen(sep->arg[1]) == 0) || (!(c->GetTarget() && c->GetTarget()->IsClient()))) {
|
||||
c->Message(Chat::White, "Usage: #name newname (requires player target)");
|
||||
int arguments = sep->argnum;
|
||||
if (!arguments) {
|
||||
c->Message(Chat::White, "Usage: #name [New Name] - Rename your player target");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
target = c->GetTarget()->CastToClient();
|
||||
char *oldname = strdup(target->GetName());
|
||||
if (target->ChangeFirstName(sep->arg[1], c->GetName())) {
|
||||
c->Message(Chat::White, "Successfully renamed %s to %s", oldname, sep->arg[1]);
|
||||
// until we get the name packet working right this will work
|
||||
c->Message(Chat::White, "Sending player to char select.");
|
||||
target->Kick("Name was changed");
|
||||
}
|
||||
else {
|
||||
|
||||
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||
auto target = c->GetTarget()->CastToClient();
|
||||
|
||||
std::string new_name = sep->arg[1];
|
||||
std::string old_name = target->GetCleanName();
|
||||
|
||||
if (target->ChangeFirstName(new_name.c_str(), c->GetCleanName())) {
|
||||
c->Message(
|
||||
Chat::Red,
|
||||
"ERROR: Unable to rename %s. Check that the new name '%s' isn't already taken.",
|
||||
oldname,
|
||||
sep->arg[2]
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Successfully renamed {} to {}",
|
||||
old_name,
|
||||
new_name
|
||||
).c_str()
|
||||
);
|
||||
|
||||
c->Message(Chat::White, "Sending player to char select.");
|
||||
|
||||
target->Kick("Name was changed");
|
||||
} else {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Unable to rename {}. Check that the new name '{}' isn't already taken.",
|
||||
old_name,
|
||||
new_name
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
free(oldname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user