Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant compare Item Name with normal string
#1
Cant compare Item Name with normal string
Reply
#2
Are you sure your names are correct? Backpacks for example are named Backpack (Lv.2).
Reply
#3
It could be encoding or something also tr3x posted a list of all ids so you could just use them https:
Reply
#4
What is the value of name? Try printing it out and see if you're getting actual items names, or garbage
Reply
#5
Also, check if the string doesn't have a white space at the end...
Reply
#6
Use string.equals with invariantcultureignorecase and see if error persists
Reply
#7
It's also possible the code is reading the null character at the end. In that case you'll need to read (length-1)*2 bytes. I got the 'length' parameter from here , which I assumed was the length of the string, but looking at the actual SDK it appears to be the length of the array (inherited from TArray). I've never run into this in my own code because it appears I never compare strings, only IDs I've updated the code in the original thread .
Reply
#8
Quote: Originally Posted by Neonreflexe now if I do Code: if ( name == "Backpack (Level 2)" ) { Console . WriteLine ( "Hi" ); } it doesnt write anything even tho Console.WriteLine(name); print me "Backpack (Level 2)" does anyone have some ideas on why this happens? thanks! The correct name is "Backpack Lv.2"
Reply
#9
You guys were correct - there was some kind of null char in the string. Thanks for the solution @ ajaroflube
Reply
#10
i copied Striekcarl code for that and just trim the string and its fine for me.
Reply




Users browsing this thread: 1 Guest(s)