• 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.

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 8
Joined
Dec 20, 2007
Messages
128
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