• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

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?
 
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:
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.
Back
Top