@heipp123_1 What you’re asking is probably a different function than the code you posted. I guess you could do it by comparing the username to a specific string, and only printing it if they match, but there’s probably a better way.
The code that you added is doing exactly what it’s supposed to be doing, though, so it’s working properly.
Nah, you’re good. I understood exactly what you were going for. I may not have done a good enough job explaining how to approach your goal.
Not to offend you, but do you understand what the code that you posted does? If not, and you want to continue developing games, it’s pretty important to learn. Thankfully, Unity provides a great tutorial series to get started.
If you’re not into learning and just want to do this and be done with it, modify the code you had posted to this:
void GetAndPrintPlayerScore(string textStream, string playerName) {
string[] entries = textStream.Split(new char[] {'\n'}, System.StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < entries.Length; i ++) {
string[] entryInfo = entries[i].Split(new char[] {'|'});
string username = entryInfo[0];
if (username == playerName) {
int score = int.Parse(entryInfo[1]);
print(username + ": " + score);
return;
}
}
}
And call it like
GetAndPrintPlayerScore("_WHATEVER_WAS_ALREADY_HERE_", "Bozo the Clown");