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

[JASS] Set name to entered chat-string?

Status
Not open for further replies.
Hi there, I am usualy a GUI user, but sometimes GUI doesnt have what it takes.. And where that is.. JASS comes in handy!! ^^

So this is what i want help with:

How can i change the name for example "player 1" IF "player 1" types the chat message: -changename Lich King
________________
Example Before:
Player 1: Hi all ^^
-------------------
Example After:
Lich King: Hi all ^^

________________

Thx in advance!! :infl_thumbs_up:

Kindest Regards //ReDbEaN
 
Well, that was actually what i was trying to do ^^

You mean like:
JASS:
function Trig_NameChange_Actions takes nothing returns nothing
    call SetPlayerName( Player(1), GetEventPlayerChatString() )
endfunction

//===========================================================================
function InitTrig_NameChange takes nothing returns nothing
    set gg_trg_NameChange = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_NameChange, Player(1), "-setname Lich King", false )
    call TriggerAddAction( gg_trg_NameChange, function Trig_NameChange_Actions )
endfunction
 
Here we go I think ^^

IT WORKED :infl_thumbs_up:

I have been sitting here with the editor for weeks now, (unempleyed)..
My brain will soon blow up cause of all the thinking :/

JASS:
function Trig_setname_P1_Actions takes nothing returns nothing
    call SetPlayerName( GetTriggerPlayer(), SubStringBJ(GetEventPlayerChatString(), 9, StringLength(GetEventPlayerChatString())) )
endfunction

//===========================================================================
function InitTrig_setname_P1 takes nothing returns nothing
    set gg_trg_setname_P1 = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_setname_P1, Player(0), "-setname", false )
    call TriggerAddAction( gg_trg_setname_P1, function Trig_setname_P1_Actions )
endfunction
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
In case you want, this can be easly done in GUI like this

  • Name System
    • Events
      • Player - Player 1 (Red) types a chat message containing Name as A substring
      • Player - Player 2 (Blue) types a chat message containing Name as A substring
      • Player - Player 3 (Teal) types a chat message containing Name as A substring
      • Player - Player 4 (Purple) types a chat message containing Name as A substring
      • Player - Player 5 (Yellow) types a chat message containing Name as A substring
      • Player - Player 6 (Orange) types a chat message containing Name as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 4)) Equal to Name
    • Actions
      • Player - Set name of (Triggering player) to (Substring((Entered chat string), 6, (Length of (Entered chat string))))
 
Status
Not open for further replies.
Top