• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

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
119
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