Can a script be used to provide an in-game player search feature?

I have very little experience in coding, but I want to know if it is possible to perform the titular action. I know that games can access friend lists and profiles of specific players, but can a game search through accounts? What I hope to achieve is a script that searches through all accounts to count how many players have any one display name, and, if it is in the realm of possibility, to have this script then filter those players into a smaller list based on inventory items. I understand that functions similar to this can be performed, such as the aforementioned, but I have not been able to find any clear information on this specific task. All I hope to find here is whether or not this is possible, and if so, some general points on how it would be achieved. Thank you!