• 💀 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!

[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