• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] SubString off BattleTag in JASS

Status
Not open for further replies.
Level 2
Joined
Jun 30, 2017
Messages
9
Hey All,

I develop a map that is heavily dependent on the users's name for it's Rank Codes (load codes). So with the 1.32 update, all users have their BattleTags added...I want to just peel those off so that people can still use their load codes.

CoolPlayer#1234 I need to convert to just CoolPlayer

In Excel, I would do the following. Any thoughts on the easiest way to do this in JASS?
=MID(playerName,1,FIND("#",playerName)-1)
 
Level 4
Joined
May 18, 2018
Messages
38
It's always 4 numbers right? If so this should work I imagine.

Code:
function GetPlayerNameNoTag takes string playerName returns string
    return SubString(playerName, 0, StringLength(playerName) - 5)
endfunction

just call it with GetPlayerNameNoTag(GetPlayerName(yourplayerhere)).
 
Level 2
Joined
Jun 30, 2017
Messages
9
I doubt it's just 4 characters, that would only leave them 10,000 players on Battlenet. Even if it's only 4 today, it might be nice to future-proof it once they run out of numbers if they haven't already.

Anyone know how to do the find string within string?

I guess I could always loop over the string, comparing each character to "#", finding the index of that instance, and do a SubString(0,that value). Was just wondering if there was a simpler way to do it via a normal function.
 
Level 2
Joined
Jun 30, 2017
Messages
9
Ah ok. Cool thanks! I was familiar enough with the BattleTags so wasn’t sure how they worked. I’ll start with this for now and if I have to change again, I’ll do that!

Thanks for the help!
 
Level 2
Joined
Jun 30, 2017
Messages
9
So that worked for most people. Issue is people with long usernames it seems, pink would have 2 more letters in his name, but it’s getting cut off.

Also for some reason 2 of the guys still have #...so I’m guessing the numbers have gone out to 5 digits now...
1897D1C3-5383-4BFE-B81C-72A68CB93D1F.jpeg
 
Level 2
Joined
Jun 30, 2017
Messages
9
Yeah, I’ll have to figure out the Jass for that this weekend maybe. I always hate loops :) my brain hates thinking about them
 
Status
Not open for further replies.
Top