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

[Trigger] Rename Player

Status
Not open for further replies.
Level 4
Joined
Sep 24, 2007
Messages
67
I need help with a something that I haven't been able to figure out by teaching myself or learning from other's maps. Here it is:
How to change your name ingame, for example, Red types "-rename <name>" and it changes his name from Red to <name>. Let's say his starting name is Jack and so ingame he types "-rename Bob" and his name becomes Bob. If anyone could explain a way to do this I would be grateful.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Well you get the event to trigger when the player types -rename as a sub string. Then you check if the -rename is in the right location to stop any misfires occuring. Finaly you change the players name to the substring of the entered chat string that contains the desired name but not the activator (-rename is not included in the name).

It is that simple.
 
Level 5
Joined
Apr 12, 2007
Messages
158
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Length of (Entered chat string)) Greater than 27
      • Then - Actions
        • Set name = (Substring((Entered chat string), 7, 27))
      • Else - Actions
        • Set name = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
    • Player - Set name of (Triggering player) to name
This is what I have for action. "name" is a string-type variable.
 
Level 4
Joined
Sep 24, 2007
Messages
67
Doctor is right, that was kind of a given, I ovbviously don't want the whole screen to be taken up every time someone types a message.
 
Level 5
Joined
Apr 12, 2007
Messages
158
  • Actions
    • Player - Set name of (Triggering player) to (Substring((Entered chat string), 7, 27))
Or use this more efficent method since if I am not mistaken WC3 permits substrings of longer than the actual string without altering or repeating the contense.

I should test that out. =0
 
Level 5
Joined
Apr 12, 2007
Messages
158
There should be a Condition then a If/Then/Else multi actions before the Player-type action.

Here's the condition for starters:
  • (Substring((Entered chat string), 1, 6)) Equal to -name
Make sure the "-name" has a space after the "e" like this -name .
 
Level 5
Joined
Apr 12, 2007
Messages
158
The first condition should be string comparison and for the "If" condition, it should be integer comparison.
 
Status
Not open for further replies.
Top