public void InstanceMapEnter(WS_PlayerData.CharacterObject objCharacter) { if (WorldServiceLocator._WS_Maps.Maps[objCharacter.MapID].Type == MapTypes.MAP_COMMON) { objCharacter.instance = 0u; objCharacter.SystemMessage(WorldServiceLocator._Functions.SetColor("You are not in instance.", 200, 0, byte.MaxValue)); return; } InstanceMapUpdate(); DataTable q = new(); WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT * FROM characters_instances WHERE char_guid = {objCharacter.GUID} AND map = {objCharacter.MapID};", ref q); if (q.Rows.Count > 0) { objCharacter.instance = Conversions.ToUInteger(q.Rows[0]["instance"]); objCharacter.SystemMessage(WorldServiceLocator._Functions.SetColor($"You are in instance #{objCharacter.instance}, map {objCharacter.MapID}", 0, 200, byte.MaxValue)); SendInstanceMessage(ref objCharacter.client, objCharacter.MapID, Conversions.ToInteger(Operators.SubtractObject(q.Rows[0]["expire"], WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)))); return; } if (objCharacter.IsInGroup) { WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT * FROM characters_instances_group WHERE group_id = {objCharacter.Group.ID} AND map = {objCharacter.MapID};", ref q); if (q.Rows.Count > 0) { objCharacter.instance = Conversions.ToUInteger(q.Rows[0]["instance"]); objCharacter.SystemMessage(WorldServiceLocator._Functions.SetColor($"You are in instance #{objCharacter.instance}, map {objCharacter.MapID}", 245, 245, byte.MaxValue)); SendInstanceMessage(ref objCharacter.client, objCharacter.MapID, Conversions.ToInteger(Operators.SubtractObject(q.Rows[0]["expire"], WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)))); return; } } checked { var instanceNewID = (int)InstanceMapCreate(objCharacter.MapID); var instanceNewResetTime = (int)(WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now) + WorldServiceLocator._WS_Maps.Maps[objCharacter.MapID].ResetTime); objCharacter.instance = (uint)instanceNewID; if (objCharacter.IsInGroup) { WorldServiceLocator._WorldServer.CharacterDatabase.Update($"INSERT INTO characters_instances_group (group_id, map, instance, expire) VALUES ({objCharacter.Group.ID}, {objCharacter.MapID}, {instanceNewID}, {instanceNewResetTime});"); } InstanceMapSpawn(objCharacter.MapID, (uint)instanceNewID); objCharacter.SystemMessage(WorldServiceLocator._Functions.SetColor($"You are in instance #{objCharacter.instance}, map {objCharacter.MapID}", 245, 245, byte.MaxValue)); SendInstanceMessage(ref objCharacter.client, objCharacter.MapID, (int)(WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now) - instanceNewResetTime)); } }