Core/Commands: Fixes teleporting to guid/name creatures.

This commit is contained in:
hondacrx
2021-01-27 14:57:05 -05:00
parent 869aa6bf56
commit a6c1f98856
+19 -10
View File
@@ -39,29 +39,38 @@ namespace Game.Chat.Commands
Player player = handler.GetSession().GetPlayer(); Player player = handler.GetSession().GetPlayer();
// "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
string param1 = handler.ExtractKeyFromLink(args, "Hcreature", "Hcreature_entry"); string param1 = handler.ExtractKeyFromLink(args, "Hcreature");
if (string.IsNullOrEmpty(param1)) if (param1.IsEmpty())
return false; return false;
string whereClause = ""; string whereClause = "";
// User wants to teleport to the NPC's template entry // User wants to teleport to the NPC's template entry
if (param1.IsNumber()) if (param1.Equals("id"))
{ {
if (!int.TryParse(param1, out int entry) || entry == 0) // Get the "creature_template.entry"
{ // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
if (!ulong.TryParse(param1, out ulong guidLow) || guidLow == 0) string id = handler.ExtractKeyFromLink(args, "Hcreature_entry");
if (id.IsEmpty())
return false;
if (!uint.TryParse(id, out uint entry))
return false; return false;
whereClause += "WHERE guid = '" + guidLow + '\'';
}
else
whereClause += "WHERE id = '" + entry + '\''; whereClause += "WHERE id = '" + entry + '\'';
} }
else else
{
ulong.TryParse(param1, out ulong guidLow);
if (guidLow != 0)
{
whereClause += "WHERE guid = '" + guidLow + '\'';
}
else
{ {
// param1 is not a number, must be mob's name // param1 is not a number, must be mob's name
whereClause += ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name LIKE '" + param1 + '\''; whereClause += ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name LIKE '" + args.GetString() + '\'';
}
} }
SQLResult result = DB.World.Query("SELECT position_x, position_y, position_z, orientation, map FROM creature {0}", whereClause); SQLResult result = DB.World.Query("SELECT position_x, position_y, position_z, orientation, map FROM creature {0}", whereClause);