public static bool TryConsume(out dynamic value, Type type, StringArguments args) { value = default; HyperlinkInfo info = ParseHyperlink(args.GetString()); // invalid hyperlinks cannot be consumed if (info == null) { return(false); } // store value switch (Type.GetTypeCode(type)) { case TypeCode.UInt32: { if (!uint.TryParse(info.Data, out uint tempValue)) { return(false); } value = tempValue; return(true); } case TypeCode.UInt64: { if (!ulong.TryParse(info.Data, out ulong tempValue)) { return(false); } value = tempValue; return(true); } case TypeCode.String: { value = info.Data; return(true); } case TypeCode.Object: return(TryConsumeObject(out value, type, info)); } return(false); }
static bool SetMotd(StringArguments args, CommandHandler handler) { Global.WorldMgr.SetMotd(args.NextString("")); handler.SendSysMessage(CypherStrings.MotdNew, args.GetString()); return(true); }
static bool HandleGoCreatureCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } Player player = handler.GetSession().GetPlayer(); // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r string param1 = handler.ExtractKeyFromLink(args, "Hcreature"); if (param1.IsEmpty()) { return(false); } string whereClause = ""; // User wants to teleport to the NPC's template entry if (param1.Equals("id")) { // Get the "creature_template.entry" // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r string id = handler.ExtractKeyFromLink(args, "Hcreature_entry"); if (id.IsEmpty()) { return(false); } if (!uint.TryParse(id, out uint entry)) { return(false); } whereClause += "WHERE id = '" + entry + '\''; } 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 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); if (result.IsEmpty()) { handler.SendSysMessage(CypherStrings.CommandGocreatnotfound); return(false); } float x = result.Read <float>(0); float y = result.Read <float>(1); float z = result.Read <float>(2); float o = result.Read <float>(3); uint mapId = result.Read <ushort>(4); if (result.NextRow()) { handler.SendSysMessage(CypherStrings.CommandGocreatmultiple); } if (!GridDefines.IsValidMapCoord(mapId, x, y, z, o) || Global.ObjectMgr.IsTransportMap(mapId)) { handler.SendSysMessage(CypherStrings.InvalidTargetCoord, x, y, mapId); return(false); } // stop flight if need if (player.IsInFlight()) { player.GetMotionMaster().MovementExpired(); player.CleanupAfterTaxiFlight(); } // save only in non-flight case else { player.SaveRecallPosition(); } player.TeleportTo(mapId, x, y, z, o); return(true); }