From bf549b538659f3fab4865489f914b9a5f7c7e511 Mon Sep 17 00:00:00 2001 From: WarrentyExpired Date: Wed, 4 Nov 2026 13:37:59 -0500 Subject: [PATCH] #W# Command: [ECN command for exporting CitizenNodes. --- .../Decoration/Exported/TownMeetingSpots.cfg | 67 ++++++++++++++++++ .../UOContent/Commands/ExportCitizenNodes.cs | 68 +++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 Distribution/Data/Decoration/Exported/TownMeetingSpots.cfg create mode 100644 Projects/UOContent/Commands/ExportCitizenNodes.cs diff --git a/Distribution/Data/Decoration/Exported/TownMeetingSpots.cfg b/Distribution/Data/Decoration/Exported/TownMeetingSpots.cfg new file mode 100644 index 000000000..ca8eb2deb --- /dev/null +++ b/Distribution/Data/Decoration/Exported/TownMeetingSpots.cfg @@ -0,0 +1,67 @@ +# Auto-generated CitizenNode export file +# Exported on 2026-11-04 13:33:51 + +CitizenNode 0x1BCE (NodeType=MeetingSpot) +1818 1995 0 +1854 1967 0 +1880 1968 0 +1855 2015 0 +1869 2044 0 +1833 2027 0 +1798 2044 0 +1771 2001 0 +363 1230 0 +392 1283 0 +339 1299 0 +450 1301 0 +426 1304 0 +2332 2778 0 +2294 2806 0 +2227 2816 0 +2248 2830 0 +2351 2825 0 +2353 2796 0 +756 1225 0 +778 1267 0 +745 1301 1 +795 1300 1 +1160 1685 0 +1211 1691 0 +1244 1757 0 +1139 1753 0 +1333 1682 0 +1364 1696 0 +1445 1688 0 +1409 1743 0 +1388 1729 0 +1352 1766 0 +1384 1737 0 +418 1856 1 +463 1834 1 +456 1901 1 +381 1886 1 +1575 2894 2 +1551 2926 2 +1575 2922 2 +1615 2943 2 +1580 2970 2 +3353 2403 1 +3394 2386 2 +3402 2374 2 +3357 2346 1 +3485 393 2 +3501 403 2 +3529 395 2 +3510 358 2 +1787 1357 2 +1813 1370 2 +1794 1411 2 +1789 1384 2 +1727 1453 2 +3351 3674 0 +3351 3633 1 +3404 3741 0 +3423 3717 0 +3465 3664 0 +3379 3616 0 + diff --git a/Projects/UOContent/Commands/ExportCitizenNodes.cs b/Projects/UOContent/Commands/ExportCitizenNodes.cs new file mode 100644 index 000000000..8ac82b44f --- /dev/null +++ b/Projects/UOContent/Commands/ExportCitizenNodes.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Server; +using Server.Commands; +using Server.Items; + +namespace Server.Commands +{ + public static class ExportCitizenNodes + { + public static void Configure() + { + CommandSystem.Register("ExportCitizenNodes", AccessLevel.GameMaster, ExportCitizenNodes_OnCommand); + } + + [Usage("ExportCitizenNodes")] + [Aliases("ExportCitizenNodes", "ECN")] + [Description("Exports all deployed CitizenNodes into a decoration .cfg file format.")] + private static void ExportCitizenNodes_OnCommand(CommandEventArgs e) + { + var mobile = e.Mobile; + + var nodes = World.Items.Values + .OfType() + .Where(n => !n.Deleted && n.Map != null && n.Map != Map.Internal) + .ToList(); + + if (nodes.Count == 0) + { + mobile.SendMessage("No active CitizenNodes were found in the world."); + return; + } + + string folderPath = Path.Combine(Core.BaseDirectory, "Data", "Decoration", "Exported"); + if (!Directory.Exists(folderPath)) + { + Directory.CreateDirectory(folderPath); + } + + string filePath = Path.Combine(folderPath, "CitizenNodes.cfg"); + + using (var writer = new StreamWriter(filePath, false)) + { + writer.WriteLine("# Auto-generated CitizenNode export file"); + writer.WriteLine($"# Exported on {DateTime.Now:yyyy-MM-dd HH:mm:ss}"); + writer.WriteLine(); + + // Group nodes by NodeType so the config file remains clean and organized + foreach (var group in nodes.GroupBy(n => n.NodeType)) + { + int itemID = group.First().ItemID; + writer.WriteLine($"CitizenNode 0x{itemID:X} (NodeType={group.Key})"); + + foreach (var node in group) + { + writer.WriteLine($"{node.X} {node.Y} {node.Z}"); + } + + writer.WriteLine(); + } + } + + mobile.SendMessage($"Successfully exported {nodes.Count} CitizenNode(s) to '{filePath}'."); + } + } +}