/// <summary> /// Changes the current faction of selected Unit (byte Faction) /// </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 ModifyFaction(Player plr, ref List <string> values) { byte faction = (byte)GetInt(ref values); byte save = (byte)(values.Count > 0 ? GetInt(ref values) : 0); Object obj = GetObjectTarget(plr); RegionMgr region = obj.Region; ushort zoneId = obj.Zone.ZoneId; obj.RemoveFromWorld(); obj.GetUnit().SetFaction(faction); region.AddObject(obj.GetUnit(), zoneId, true); if (save > 0) { if (obj.IsCreature()) { Creature crea = obj.GetCreature(); crea.Spawn.Faction = faction; WorldMgr.Database.SaveObject(crea.Spawn); } } return(true); }