I'm trying to get players who have a custom item with item_component, but it's not working.
I want to know how to get players who have a custom item with item_component.
var InventoryToAgent : [inventory_component]agent = map{}
OnSimulate<override>()<suspends>:void =
if (Playspace := Entity.GetPlayspaceForEntity[]):
Players := Playspace.GetPlayers()
for(Player : Players, FC := Player.GetFortCharacter[]):
if(ItemComp := Entity.GetComponent[item_component]):
Print("ItemComp")
if(ParentInv := ItemComp.GetParentInventory[]):
Print("ParentInv")
if (Agent := InventoryToAgent[ParentInv]):
Print("Agent")
if(FC = Agent.GetFortCharacter[]):
Print("FC")
Super late lol but I think you’d have to create a custom item prefab entity first. Then get the player entity, then get (PlayerInventory := GetComponent[inventory_component]), then AllItems := PlayerInventory.findallitems[], then cast them to your custom item prefab entity CustomItemsArray := AllItems[custom_item_prefab], then check if CustomItemsArray > 0 to result in true/false. If true, add that player to an array of players who have this item using a ‘for loop’.