Forum rules - please read before posting.

Check if any player is carrying an item (solved)

edited July 2021 in Technical Q&A

I need to check whether any player is carrying a specific item (in a game allowing multiple players).
But the ActionInventoryCheck only checks if currently active player is carrying the item (even if no specific player is chosen).

Any ideas on how to check this in code?

Thanks

Update:
Though the action should possibly do this automatically for game supporting multiple players, here's how it can be done:

var isCarriedByAnyPlayer = KickStarter.settingsManager.players
    .Any(o => KickStarter.runtimeInventory.GetCount(invItem.id, o.ID) > 0);

Comments

  • If the Action's Check specific Player? option is unchecked, only the active Player will be queried.

    I agree it would be best to have a choice between checking the active Player, a specific Player, and "any" Player. I'll look into this.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.