• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Unit's Name

Status
Not open for further replies.
Level 7
Joined
Apr 3, 2007
Messages
293
How do u allow ppl change a units name in the game? I created variable named Units_Name, and set it as a string, I want it to set that variable as the chat message that a player typed, so this is what I do...
  • Event- Player - Player types a chat message contaning " - " as A substring
  • Condition- None
  • Action- Set Unit Name = _______
What I just did was set "- 'whatever u want the name to be'" text to be able to activate this trigger.
BUT JUST IGNOR EVERYTHING ELSE IF U R CONFUSED. What I need to know is, how do I set a string variable to a sertant text that someone typed, and how to I set the string variable as a unit's name?
 
Level 7
Joined
Dec 20, 2007
Messages
124
Here Found This On My Messy Folders Inside a Text

JASS:
function SetHeroProperName_Child takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GetHandleUnit(t, "Hero")
    local unit n = ReplaceUnitBJ(u, GetUnitTypeId(u), bj_UNIT_STATE_METHOD_RELATIVE)
    call SetHandleHandle(t, "Hero", n)
    if (GetHandleString(t, "Name") == SubStringBJ(GetHeroProperName(n), 1, StringLength(GetHandleString(t, "Name")))) then
        set bj_lastHauntedGoldMine = n
        call FlushHandleLocals(t)
        call DestroyTimer(t)
    endif
    set t = null
    set u = null
    set n = null
endfunction

function SetHeroProperName takes unit whichHero, string newName returns nothing
    local timer t = CreateTimer()
    call SetHandleHandle(t, "Hero", whichHero)
    call SetHandleString(t, "Name", newName)
    call TimerStart(t, 0.00, true, function SetHeroProperName_Child)
    set whichHero = null
    set t = null
endfunction

I don't remember where I got this, it was a long time ago.
I can't even understand this xD
 
Last edited by a moderator:
Level 19
Joined
Aug 24, 2007
Messages
2,888
Well your function repleaces that unit with same unit until he gets the proper name you typed
So you need to type every possible propername to hero
(a,aa,aaa,aaaa,aaaaa,aaaaaa,ab,abbbb..................)
good luck
 
Status
Not open for further replies.
Top