Мне необходимо достать из hashset каждый элемент и запихнуть в команду вот код:
C#:
HashSet<Item> serverItems = new HashSet<Item>();
void OnEntitySpawned(BaseNetworkable entity)
{
if (entity == null) return;
var item = entity?.GetComponent<Item>() ?? null;
if (item != null && item.name == "Медаль") serverItems.Add(item);
}
void FindEntity()
{
var dropped = GameObject.FindObjectsOfType<DroppedItem>();
var storage = GameObject.FindObjectsOfType<StorageContainer>();
for (int i = 0; i < dropped.Length; i++)
{
var item = dropped[i]?.item ?? null;
if (item == null) continue;
if (item.name == "Медаль")
serverItems.Add(item);
}
for (int i = 0; i < storage.Length; i++)
{
var container = storage[i]?.inventory?.itemList ?? null;
for (int j = 0; j < container.Count; j++)
{
if (container[j].name == "Медаль")
{
serverItems.Add(container[j]);
}
}
}
for (int i = 0; i < BasePlayer.activePlayerList.Count; i++)
{
var player = BasePlayer.activePlayerList[i];
var items = player?.inventory?.AllItems() ?? null;
if (items != null && items.Length > 0)
{
for (int j = 0; j < items.Length; j++)
{
if (items[j].name == "Медаль")
{
serverItems.Add(items[j]);
}
}
}
}
for (int i = 0; i < BasePlayer.sleepingPlayerList.Count; i++)
{
var player = BasePlayer.sleepingPlayerList[i];
var items = player?.inventory?.AllItems() ?? null;
if (items != null && items.Length > 0) for (int j = 0; j < items.Length; j++) if (items[j].name == "Медаль") serverItems.Add(items[j]);
}
}
[ChatCommand("event-marker")]
void markercall(BasePlayer player)
{
if (!permission.UserHasPermission(player.UserIDString, "Events.use"))
{
SendReply(player, "You do not have permission for this");
return;
}
markerCreate();
}
void markerCreate()
{
for (int j = 0; j < serverItems.Count; j++)
{
Interface.CallHook("API_CreateMarker", serverItems.GetObjectData(Item), "Medal", 0, 10f, 0.4f, "Medal", "00FFFF", "00FFFFFF", 0.6f);
}
}