/// <summary> /// Delete the target <(0=World,1=Database)> /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool NpcRemove(Player plr, ref List <string> values) { Object obj = GetObjectTarget(plr); if (!obj.IsCreature()) { return(false); } int database = GetInt(ref values); obj.Dispose(); if (database > 0) { Creature_spawn spawn = obj.GetCreature().Spawn; WorldMgr.Database.DeleteObject(spawn); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "REMOVE CREATURE " + spawn.Entry + " " + spawn.Guid + " AT " + spawn.ZoneId + " " + spawn.WorldX + " " + spawn.WorldY; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); } plr.SendClientMessage("NPC REMOVE: Removed " + obj.GetCreature().Spawn.Guid); return(true); }
/// <summary> /// Add item to player /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool AddItem(Player plr, ref List <string> values) { int itemId = GetInt(ref values); int count = 1; if (values.Count > 0) { count = GetInt(ref values); } Player targetPlr = GetTargetOrMe(plr) as Player; if (targetPlr.ItmInterface.CreateItem((uint)itemId, (ushort)count) == ItemResult.RESULT_OK) { GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "ADDED " + count + " OF " + ItemService.GetItem_Info((uint)itemId).Name + " TO " + targetPlr.Name; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); } else { plr.SendClientMessage($"Item creation failed: {itemId}"); } return(true); }
/// <summary> /// Teleports you to a player's location (string playerName) /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool TeleportAppear(Player plr, ref List <string> values) { string playerName = GetString(ref values); Player target = Player.GetPlayer(playerName); if (target == null) { plr.SendClientMessage($"TELEPORT APPEAR: {playerName} could not be found."); return(true); } if (target.Zone == null) { return(false); } plr.Teleport(target.Region, target.Zone.ZoneId, (uint)target.WorldPosition.X, (uint)target.WorldPosition.Y, (ushort)target.WorldPosition.Z, target.Heading); GMCommandLog log = new GMCommandLog { PlayerName = plr.Name, AccountId = (uint)plr.Client._Account.AccountId, Command = $"TELEPORTED TO PLAYER {target.Name} AT ZONE {target.Zone.ZoneId} LOCATION {target._Value.WorldX} {target._Value.WorldY}", Date = DateTime.Now }; CharMgr.Database.AddObject(log); return(true); }
/// <summary> /// Add tok to player /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool AddTok(Player plr, ref List <string> values) { int tokEntry = GetInt(ref values); Tok_Info info = TokService.GetTok((ushort)tokEntry); if (info == null) { return(false); } plr = GetTargetOrMe(plr) as Player; plr.TokInterface.AddTok(info.Entry); GMCommandLog log = new GMCommandLog { PlayerName = plr.Name, AccountId = (uint)plr.Client._Account.AccountId, Command = "ADD TOK TO " + plr.Name + " " + tokEntry, Date = DateTime.Now }; CharMgr.Database.AddObject(log); return(false); }
/// <summary> /// Sets offline/online players coordinates in database (player_name byte byte ZoneID , uint WorldX, uint WorldY, uint WorldZ) /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool TeleportSet(Player plr, ref List <string> values) { string playerName = GetString(ref values); int zoneID = GetZoneId(plr, ref values); if (zoneID == -1) { return(false); } int worldX = GetInt(ref values); int worldY = GetInt(ref values); int worldZ = GetInt(ref values); Zone_Info zone = ZoneService.GetZone_Info((ushort)zoneID); if (zone == null) { zone = ZoneService._Zone_Info[0]; } var existingChar = CharMgr.GetCharacter(Player.AsCharacterName(playerName), false); if (existingChar == null) { plr.SendClientMessage("Player with name '" + values[0] + "' not found.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR); return(true); } var player = Player.GetPlayer(playerName); GMCommandLog log = new GMCommandLog { PlayerName = plr.Name, AccountId = (uint)plr.Client._Account.AccountId, Command = "TELEPORT offline player '" + existingChar.Name + "' TO " + zoneID + " " + worldX + " " + worldY, Date = DateTime.Now }; CharMgr.Database.AddObject(log); if (player != null) { player.Teleport((ushort)zoneID, (uint)worldX, (uint)worldY, (ushort)worldZ, 0); } existingChar.Value.WorldX = worldX; existingChar.Value.WorldY = worldY; existingChar.Value.WorldZ = worldZ; existingChar.Value.ZoneId = zone.ZoneId; existingChar.Value.RegionId = zone.Region; CharMgr.Database.SaveObject(existingChar.Value); CharMgr.Database.ForceSave(); return(true); }
/// <summary> /// Changes the name of the guild by ID (int guildID string guildName) /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool ModifyGuildNameByID(Player plr, ref List <string> values) { if (values.Count < 2) { plr.SendClientMessage("Usage: .modify guildnamebyid <guildID> <guildName>"); return(true); } uint guildID = (uint)(int)GetInt(ref values); string guildName = GetTotalString(ref values).Trim(); if (string.IsNullOrEmpty(guildName)) { plr.SendClientMessage("you need to specify a new guild name"); return(true); } Guild guild = Guild.GetGuild(guildID); if (guild == null) { plr.SendClientMessage("The Specified guild does not exist"); return(true); } if (Guild.GetGuild(guildName) != null) { plr.SendClientMessage("That guildname is already taken"); return(true); } else { plr.SendClientMessage("Changing from " + guild.Info.Name + " to " + guildName); if (guild.Info.AllianceId != 0) { guild.LeaveAlliance(); //sanity in case of packet changes with guild name change on guild inside alliance } GMCommandLog log = new GMCommandLog { PlayerName = plr.Name, AccountId = (uint)plr.Client._Account.AccountId, Command = "CHANGED GUILDNAME OF: " + guild.Info.Name + " TO: " + guildName, Date = DateTime.UtcNow }; CharMgr.Database.AddObject(log); guild.Info.Name = guildName; CharMgr.ChangeGuildName(guild.Info, guildName); return(true); } }
/// <summary> /// Delete the specified ticket /// </summary> /// <param name="plr"></param> /// <param name="values"></param> /// <returns></returns> public static bool DeleteTicket(Player plr, ref List <string> values) { if (values.Count < 1) { plr.SendClientMessage("Usage: .ticket deleteticket <bugtrackerID>"); return(true); } string reportID = GetTotalString(ref values).Trim(); if (string.IsNullOrEmpty(reportID)) { plr.SendClientMessage("you need to specify the ticketID"); return(true); } Bug_report report = CharMgr.GetReport(reportID); if (report == null) { plr.SendClientMessage("The Specified report does not exist"); return(true); } if (report.Assigned != plr.Client._Account.Username) { plr.SendClientMessage("You cannot close a ticket not assigned to you(username), assign it to yourself first if you fixed the ticket"); return(true); } else { plr.SendClientMessage("You have deleted ticket: " + reportID); GMCommandLog log = new GMCommandLog { PlayerName = plr.Client._Account.Username, AccountId = (uint)plr.Client._Account.AccountId, Command = $"Removed Ticket: {reportID} from characterID: {report.CharacterId}. containing the following message: {report.Message} {report.FieldSting}", Date = DateTime.Now }; CharMgr.Database.AddObject(log); lock (CharMgr._report) { CharMgr._report.Remove(report); CharMgr.Database.DeleteObject(report); CharMgr.Database.ForceSave(); } return(true); } }
/// <summary> /// Spawn an npc /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool NpcSpawn(Player plr, ref List <string> values) { int entry = GetInt(ref values); Creature_proto proto = CreatureService.GetCreatureProto((uint)entry); if (proto == null) { proto = WorldMgr.Database.SelectObject <Creature_proto>("Entry=" + entry); if (proto != null) { plr.SendClientMessage("NPC SPAWN: Npc Entry is valid but npc stats are empty. No sniff data about this npc"); } else { plr.SendClientMessage("NPC SPAWN: Invalid npc entry(" + entry + ")"); } return(false); } plr.UpdateWorldPosition(); Creature_spawn spawn = new Creature_spawn(); spawn.Guid = (uint)CreatureService.GenerateCreatureSpawnGUID(); spawn.BuildFromProto(proto); spawn.WorldO = plr._Value.WorldO; spawn.WorldY = plr._Value.WorldY; spawn.WorldZ = plr._Value.WorldZ; spawn.WorldX = plr._Value.WorldX; spawn.ZoneId = plr.Zone.ZoneId; spawn.Enabled = 1; WorldMgr.Database.AddObject(spawn); var c = plr.Region.CreateCreature(spawn); c.AiInterface.SetBrain(new PassiveBrain(c)); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "SPAWN CREATURE " + spawn.Entry + " " + spawn.Guid + " AT " + spawn.ZoneId + " " + plr._Value.WorldX + " " + plr._Value.WorldY; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); return(true); }
/// <summary> /// Summons a player/group to your location (string playerName optional GROUP) /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool TeleportSummon(Player plr, ref List <string> values) { string playerName = GetString(ref values); bool group = false; if (values.Count > 1) { group = GetString(ref values).ToUpper().Trim() == "GROUP"; } Player t = Player.GetPlayer(playerName); if (t == null) { plr.SendClientMessage("TELEPORT SUMMON: " + playerName + " could not be found."); return(true); } var list = new List <Player>() { t }; if (t.WorldGroup != null && group) { list.AddRange(t.WorldGroup.GetPlayerListCopy().Where(e => e.Info.CharacterId != t.Info.CharacterId).ToList()); } foreach (var target in list) { target.Teleport(plr.Region, plr.Zone.ZoneId, (uint)plr.WorldPosition.X, (uint)plr.WorldPosition.Y, (ushort)plr.WorldPosition.Z, 0); target.IsSummoned = true; //allow summoned player to enter illegal area (if summoned to it), unset it after 30 seconds target.EvtInterface.AddEvent((player) => { ((Player)player).IsSummoned = false; }, 30000, 1, target); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "SUMMON PLAYER " + target.Name + " TO " + plr.Zone.ZoneId + " " + plr._Value.WorldX + " " + plr._Value.WorldY; log.Date = DateTime.UtcNow; CharMgr.Database.AddObject(log); target.SendLocalizeString(plr.Name, ChatLogFilters.CHATLOGFILTERS_SAY, Localized_text.TEXT_BEEN_SUMMONED_TO_X); } return(true); }
/// <summary> /// Changes the renown rank of a player (string playerName, int RenownRank) /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool ModifyRenown(Player plr, ref List <string> values) { string playerName = GetString(ref values); int renownLevel = GetInt(ref values); Player target = Player.GetPlayer(playerName); Character chara = CharMgr.GetCharacter(playerName, false); if (chara == null) { plr.SendClientMessage($"MODIFY RENOWN: The player {playerName} in question does not exist."); return(true); } int desiredRenownRank = renownLevel > 0 ? renownLevel : Math.Max(1, chara.Value.RenownRank + renownLevel); desiredRenownRank = Math.Min(100, desiredRenownRank); if (target != null) { target.SetRenownLevel((byte)desiredRenownRank); } else { chara.Value.Renown = 0; chara.Value.RenownRank = (byte)desiredRenownRank; CharMgr.Database.SaveObject(chara.Value); } if (target != plr) { plr.SendClientMessage($"MODIFY RENOWN: {playerName}'s renown rank is now {chara.Value.RenownRank}."); } GMCommandLog log = new GMCommandLog { PlayerName = plr.Name, AccountId = (uint)plr.Client._Account.AccountId, Command = renownLevel > 0 ? $"SET {playerName}'S RENOWN TO {renownLevel}" : $"REDUCED {playerName}'S RENOWN BY {-renownLevel}", Date = DateTime.Now }; CharMgr.Database.AddObject(log); return(true); }
/// <summary> /// Changes the level of the targeted player (int Rank) /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool ModifyLevel(Player plr, ref List <string> values) { int level = GetInt(ref values); plr = GetTargetOrMe(plr) as Player; plr.SetLevel((byte)level); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "SET LEVEL TO " + plr.Name + " " + level; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); return(true); }
/// <summary> /// Add money to player /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool AddMoney(Player plr, ref List <string> values) { int money = GetInt(ref values); plr = GetTargetOrMe(plr) as Player; plr.AddMoney((uint)money); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "ADDED MONEY TO " + plr.Name + " " + money; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); return(true); }
/// <summary> /// Add renown to player /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool AddRenown(Player plr, ref List <string> values) { int value = GetInt(ref values); plr = GetTargetOrMe(plr) as Player; plr.AddRenown((uint)value, false); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "ADD RENOWN TO " + plr.Name + " " + value; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); return(true); }
/// <summary> /// Change the Influence Chaptter Value /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool ModifyInf(Player plr, ref List <string> values) { int chapter = GetInt(ref values); int value = GetInt(ref values); plr = GetTargetOrMe(plr) as Player; plr.SetInfluence((ushort)chapter, (ushort)value); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "SET Influence TO " + plr.Name + " Chapter " + chapter + " Value " + value; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); return(true); }
/// <summary> /// Add Contribution to player FOR TESTING ONLY /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool AddContrib(Player plr, ref List <string> values) { int value = GetInt(ref values); plr = GetTargetOrMe(plr) as Player; plr.Region.ndbf.AddContribution(plr, (uint)value); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "ADD Infl TO " + plr.Name + " contribution Value " + value; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); plr.SendClientMessage(value + " contribution added for " + plr.Name); return(true); }
/// <summary> /// /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool RespawnAdd(Player plr, ref List <string> values) { byte realm = (byte)GetInt(ref values); Zone_Respawn respawn = new Zone_Respawn { PinX = (ushort)plr.X, PinY = (ushort)plr.Y, PinZ = (ushort)plr.Z, WorldO = plr.Heading, ZoneID = plr.Zone.ZoneId, Realm = realm }; WorldMgr.Database.AddObject(respawn); ZoneService.LoadZone_Respawn(); GameObject_proto proto = GameObjectService.GetGameObjectProto(563); GameObject_spawn spawn = new GameObject_spawn { Guid = (uint)GameObjectService.GenerateGameObjectSpawnGUID(), WorldX = plr.WorldPosition.X, WorldY = plr.WorldPosition.Y, WorldZ = plr.WorldPosition.Z, WorldO = plr.Heading, ZoneId = plr.Zone.ZoneId }; spawn.BuildFromProto(proto); plr.Region.CreateGameObject(spawn); GMCommandLog log = new GMCommandLog { PlayerName = plr.Name, AccountId = (uint)plr.Client._Account.AccountId, Command = "ADD RESPAWN TO " + plr.Zone.ZoneId + " " + (ushort)plr.X + " " + (ushort)plr.Y, Date = DateTime.Now }; CharMgr.Database.AddObject(log); return(true); }
/// <summary> /// Teleports you to the specified world coordinates in a given zone (byte ZoneID , uint WorldX, uint WorldY, uint WorldZ) /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool TeleportMap(Player plr, ref List <string> values) { int zoneID = GetZoneId(plr, ref values); if (zoneID == -1) { return(false); } int worldX = GetInt(ref values); int worldY = GetInt(ref values); int worldZ = GetInt(ref values); plr.Teleport((ushort)zoneID, (uint)worldX, (uint)worldY, (ushort)worldZ, 0); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "TELEPORT TO " + zoneID + " " + worldX + " " + worldY; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); return(true); }
/// <summary> /// To answer and close a ticket (answer will be sent as an ingame mail) /// </summary> /// <param name="plr"></param> /// <param name="values"></param> /// <returns></returns> public static bool Answer(Player plr, ref List <string> values) { if (values.Count < 2) { plr.SendClientMessage("Usage: .ticket answer <bugtrackerID> <message>"); return(true); } string reportID = GetString(ref values); string message = GetTotalString(ref values).Trim(); if (string.IsNullOrEmpty(message)) { plr.SendClientMessage("you need to specify a message to send"); return(true); } if (string.IsNullOrEmpty(reportID)) { plr.SendClientMessage("you need to specify the ticketID"); return(true); } Bug_report report = CharMgr.GetReport(reportID); if (report == null) { plr.SendClientMessage("The Specified report does not exist"); return(true); } if (report.Assigned != plr.Client._Account.Username) { plr.SendClientMessage("You cannot answer a ticket not assigned to you(username), assign it to yourself first if you want to answer this ticket"); return(true); } if (CharMgr.GetCharacter(report.CharacterId, false) == null) { plr.SendClientMessage("The player who created this ticket is deleted or has not logged in for over the preload period, as such we cannot send a mail to the character."); return(true); } else { plr.SendClientMessage("You have answered ticket: " + reportID); GMCommandLog log = new GMCommandLog { PlayerName = plr.Client._Account.Username, AccountId = (uint)plr.Client._Account.AccountId, Command = $"Answered Ticket: {reportID} from characterID: {report.CharacterId}. Containing message: {report.Message} {report.FieldSting} with the following reply: {message}", Date = DateTime.Now }; Character chara = CharMgr.GetCharacter(report.CharacterId, false); Character_mail ticketMail = new Character_mail { Guid = CharMgr.GenerateMailGuid(), CharacterId = chara.CharacterId, CharacterIdSender = chara.CharacterId, SenderName = chara.Name, ReceiverName = chara.Name, SendDate = (uint)TCPManager.GetTimeStamp(), Title = "Answered Ticket", Content = $"Your ticket has been answered by: {report.Assigned} with the following message: \n \n {message}", Money = 0, Opened = false }; CharMgr.AddMail(ticketMail); CharMgr.Database.AddObject(log); lock (CharMgr._report) { CharMgr._report.Remove(report); CharMgr.Database.DeleteObject(report); CharMgr.Database.ForceSave(); } return(true); } }
/// <summary> /// Changes players name /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool ModifyPlayerName(Player plr, ref List <string> values) { if (values.Count < 2) { plr.SendClientMessage("Usage: .modify playername old_player_name new_player_name"); return(true); } var charToRename = CharMgr.GetCharacter(Player.AsCharacterName(values[0]), false); if (charToRename == null) { plr.SendClientMessage("Player with name '" + values[0] + "' not found.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR); return(true); } var existingChar = CharMgr.GetCharacter(Player.AsCharacterName(values[1]), false); if (existingChar != null) { plr.SendClientMessage("Player with name '" + existingChar.Name + "' already exists.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR); return(true); } if (values[1].Length < 3) { plr.SendClientMessage("Player name must be at least 3 characters long.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR); return(true); } if (!values[1].All(c => char.IsLetter(c) && c <= 0x7A)) { plr.SendClientMessage("Player names may not contain special characters.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR); return(true); } string newName = values[1][0].ToString().ToUpper() + values[1].ToLower().Substring(1); CharMgr.UpdateCharacterName(charToRename, newName); var player = Player.GetPlayer(values[0]); LogSanction(player.Info.AccountId, plr, "GM issued Name Change", "", $"From {charToRename.Name} to {newName}"); GMCommandLog log = new GMCommandLog { PlayerName = plr.Name, AccountId = (uint)plr.Client._Account.AccountId, Command = "Changed player name FROM " + values[0] + " TO " + charToRename.Name, Date = DateTime.Now }; CharMgr.Database.AddObject(log); if (player != null) { player.Name = charToRename.Name; player.Quit(false, false); } plr.SendClientMessage(log.Command); return(true); }
/// <summary> /// Spawn an npc +Keep /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool NpcKeepSpawn(Player plr, ref List <string> values) { var destroId = values[0]; var orderId = values[1]; Creature_proto proto = null; Creature_proto protoOrder = null; if (destroId == "0") { plr.SendClientMessage("NPC SPAWN: Setting Destro Id -> 0"); } else { proto = CreatureService.GetCreatureProto(Convert.ToUInt32(destroId)); if (proto == null) { proto = WorldMgr.Database.SelectObject <Creature_proto>("Entry=" + destroId); if (proto != null) { plr.SendClientMessage("NPC SPAWN: Npc Entry is valid but npc stats are empty. No sniff data about this npc"); } else { plr.SendClientMessage("NPC SPAWN: Invalid npc entry(" + destroId + ")"); } return(false); } } if (orderId == "0") { plr.SendClientMessage("NPC SPAWN: Setting Order Id -> 0"); } else { protoOrder = CreatureService.GetCreatureProto(Convert.ToUInt32(orderId)); if (protoOrder == null) { protoOrder = WorldMgr.Database.SelectObject <Creature_proto>("Entry=" + orderId); if (protoOrder != null) { plr.SendClientMessage("NPC SPAWN: Npc Entry is valid but npc stats are empty. No sniff data about this npc"); } else { plr.SendClientMessage("NPC SPAWN: Invalid npc entry(" + orderId + ")"); } return(false); } } plr.UpdateWorldPosition(); //Creature_spawn spawn = new Creature_spawn { Guid = (uint)CreatureService.GenerateCreatureSpawnGUID() }; //spawn.BuildFromProto(proto); //spawn.WorldO = plr._Value.WorldO; //spawn.WorldY = plr._Value.WorldY; //spawn.WorldZ = plr._Value.WorldZ; //spawn.WorldX = plr._Value.WorldX; //spawn.ZoneId = plr.Zone.ZoneId; //spawn.Enabled = 1; //WorldMgr.Database.AddObject(spawn); var kc = new Keep_Creature(); kc.ZoneId = plr.Zone.ZoneId; kc.DestroId = Convert.ToUInt32(destroId); kc.OrderId = Convert.ToUInt32(orderId); kc.IsPatrol = false; var keep = plr.Region.Campaign.GetClosestKeep(plr.WorldPosition, (ushort)plr.ZoneId); kc.KeepId = keep.Info.KeepId; kc.KeepLord = false; kc.X = plr._Value.WorldX; kc.Y = plr._Value.WorldY; kc.Z = plr._Value.WorldZ; kc.O = plr._Value.WorldO; kc.WaypointGUID = 0; kc.Dirty = true; WorldMgr.Database.AddObject(kc); WorldMgr.Database.ForceSave(); plr.SendClientMessage("Created keep creature"); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "SPAWN KEEP CREATURE " + kc.ZoneId + " " + plr._Value.WorldX + " " + plr._Value.WorldY; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); return(true); }
/// <summary> /// Move a keep npc /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool MoveKeepSpawn(Player plr, ref List <string> values) { Object obj = GetObjectTarget(plr); if (!obj.IsCreature()) { return(false); } Creature creature = (Creature)obj; var selectedEntry = creature.Entry; var oldX = creature.WorldPosition.X; var oldY = creature.WorldPosition.Y; var oldZ = creature.WorldPosition.Z; var oldO = creature.Heading; var keep = plr.Region.Campaign.GetClosestKeep(plr.WorldPosition, (ushort)plr.ZoneId); plr.SendClientMessage(keep.Info.Name); KeepNpcCreature keepNpcCreature = null; if (keep.Realm == Realms.REALMS_REALM_DESTRUCTION) { keepNpcCreature = keep.Creatures.SingleOrDefault(x => x.Info.DestroId == selectedEntry && x.Info.X == oldX); } if (keep.Realm == Realms.REALMS_REALM_ORDER) { keepNpcCreature = keep.Creatures.SingleOrDefault(x => x.Info.OrderId == selectedEntry && x.Info.X == oldX); } if (keepNpcCreature == null) { plr.SendClientMessage($"Could not locate selected target"); return(true); } keepNpcCreature.Info.X = plr.WorldPosition.X; keepNpcCreature.Info.Y = plr.WorldPosition.Y; keepNpcCreature.Info.Z = plr.WorldPosition.Z; keepNpcCreature.Info.O = plr.Oid; keepNpcCreature.Info.WaypointGUID = Convert.ToInt32(values[0]); var sql = $"UPDATE war_world.keep_creatures " + $"SET X={keepNpcCreature.Info.X}, Y={keepNpcCreature.Info.Y}, Z = {keepNpcCreature.Info.Z}, O={keepNpcCreature.Info.O}, " + $"WaypointGUID = {keepNpcCreature.Info.WaypointGUID} " + $"where KeepId = {keep.Info.KeepId} and X={oldX} and Y={oldY} and Z={oldZ}"; WorldMgr.Database.ExecuteNonQuery(sql); keepNpcCreature.Creature.X = plr.WorldPosition.X; keepNpcCreature.Creature.Y = plr.WorldPosition.Y; plr.SendClientMessage($"Moved keep creature to new position"); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "MOVE KEEP CREATURE " + selectedEntry + " " + " AT " + keepNpcCreature.Info.ZoneId + " " + plr._Value.WorldX + " " + plr._Value.WorldY; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); return(true); }