Warcraft III resources & community, 2003–2006 · archived

SetRealNames

not rated
Submitted by Agent_VastTriggers0 downloads
People use underscores in their names rather than spaces and put numbers at the end of their usernames when they are already in use. Call SetRealNames on map init to show user's names like they should be seen.

Source

function Do_Player takes nothing returns nothing
    local string tempStr = ""
    set tempStr = GetPlayerName(GetEnumPlayer())
    call SetPlayerName( GetEnumPlayer(), "" )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = StringLength(tempStr)
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( ( GetForLoopIndexA() == 1 ) ) then
            if (( SubStringBJ(tempStr, GetForLoopIndexA(), GetForLoopIndexA()) == "_" ) ) then
                call SetPlayerName( GetEnumPlayer(), ( GetPlayerName(GetEnumPlayer()) + " " ) )
            else
                call SetPlayerName( GetEnumPlayer(), ( GetPlayerName(GetEnumPlayer()) + StringCase(SubStringBJ(tempStr, GetForLoopIndexA(), GetForLoopIndexA()), true) ) )
            endif
        else
            if (( SubStringBJ(tempStr, GetForLoopIndexA(), GetForLoopIndexA()) == "_" ) ) then
                call SetPlayerName( GetEnumPlayer(), ( GetPlayerName(GetEnumPlayer()) + " " ) )
            else
                call SetPlayerName( GetEnumPlayer(), ( GetPlayerName(GetEnumPlayer()) + SubStringBJ(tempStr, GetForLoopIndexA(), GetForLoopIndexA()) ) )
            endif
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 50
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set bj_forLoopBIndex = 0
        set bj_forLoopBIndexEnd = 9
        loop
            exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
            if ( SubStringBJ(GetPlayerName(GetEnumPlayer()), StringLength(GetPlayerName(GetEnumPlayer())), StringLength(GetPlayerName(GetEnumPlayer()))) == I2S(GetForLoopIndexB()) ) then
                call SetPlayerName( GetEnumPlayer(), SubStringBJ(GetPlayerName(GetEnumPlayer()), 1, ( StringLength(GetPlayerName(GetEnumPlayer())) - 1 )) )
            endif
            set bj_forLoopBIndex = bj_forLoopBIndex + 1
        endloop
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

function SetRealNames takes nothing returns nothing
    call ForForce( GetPlayersByMapControl(MAP_CONTROL_USER), function Do_Player )
endfunction

Comments

3
This is useless because many people have names which are either written with numbers(5 as S, 1 as I, 3 as E, and so on) or the number is a part of the name(My name is GT4 and I don't use it because there already was a "GT", I use it because it's just a name) or there is the possibility of writing numbers instead of wordpieces(Example: N8 = Night and not N #8, or N811="Nachtelf" in german=Nightelf).
This will just mix the names like crazy!
I'm sorry, Vex. :( I've fixed the Blizzard globals and the extra functions. As for the memory leak, well you're only going to be running this trigger once at map init, it's not going to make that much of a difference.
has a memory leak, uses three extra functions for no reason and blizzard globals instead of locals